⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 _exception.h

📁 http代理程序
💻 H
字号:
#ifndef ___exception_h__
#define ___exception_h__

#include <stdio.h>

#include <exception>
#include <string>
using namespace std;

namespace extension
{

// Root of all exceptions in namespace extension
class extended_exception :
	public exception
{
public:

	// Exception code
	typedef enum exception_code
	{ 
		exception_code_generic = 0xffffffffL
	} exception_code;


	// Function name	: extended_exception
	// Description	    : 
	// Return type		: 
	// Argument         : long nCode
	// Argument         : char* pDescription = "No description"
	// Argument         : char* pFile = NULL
	// Argument         : long nLine = 0
	extended_exception( long nCode, const char* pDescription = "No description", const char* pFile = "", long nLine = -1 )
	{
		m_nCode = nCode;
		m_strDescription = pDescription;
		m_strFile = pFile;
		m_nLine = nLine;
	}
	

	// Function name	: ~extended_exception
	// Description	    : 
	// Return type		: virtual 
	virtual ~extended_exception()
	{
	}


	// Function name	: char* what
	// Description	    : 
	// Return type		: virtual const 
	virtual const char* what()
	{
		sprintf( m_szBuffer, "Exception (0x%.8X): \n\t%s\n\tFile: %s \n\tLine: %d\n", m_nCode, m_strDescription.c_str(), m_strFile.c_str(), m_nLine );
		return m_szBuffer;
	}

	// Code of the exception
	long m_nCode;

	// Description for the exception
	string m_strDescription;
	// File name where the exception occured
	string m_strFile;
	// Line number where the exception occured
	long m_nLine;

private:

	// Private buffer
	char m_szBuffer[1024];
};

/*
End of stream
*/
class end_of_stream_exception :
	public extended_exception
{
public:


	// Function name	: end_of_stream_exception
	// Description	    : Exception raised when the end of stream is reached
	// Return type		: 
	// Argument         : long nCode													- exception code
	// Argument         : const char* pDescription = "End of stream exception"	- description
	// Argument         : const char* pFile = ""										- the file name where the exception has occured
	// Argument         : long nLine = -1												- the line number where the exception has occured
	end_of_stream_exception( long nCode, const char* pDescription = "End of stream", const char* pFile = "", long nLine = -1 ) :
	  extended_exception( nCode, pDescription, pFile, nLine )
	{
	}
};
	

#define throw_exception(classException, nCode, pDescription) \
	{throw classException( nCode, pDescription, __FILE__, __LINE__ );}

} // Namespace extension

#endif // ___exception_h__

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -