00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <exception>
00024 #include <string>
00025 #include <cstring>
00026 #include <cstdio>
00027
00028
00029 #ifndef EXCEPTION_HH
00030 #define EXCEPTION_HH
00031
00032
00033 class clException : public std::exception
00034 {
00035 int iCode;
00036 std::string strMsg;
00037 public:
00038 clException () throw()
00039 { }
00040 clException (int iErrorCode) throw()
00041 {
00042 char cpConvBuf[79];
00043 iCode = iErrorCode;
00044 sprintf(cpConvBuf, "%i", iErrorCode);
00045 strMsg = std::string(cpConvBuf);
00046 }
00047 clException (const std::string &strErrorMsg) throw()
00048 {
00049 iCode = 0;
00050 strMsg = strErrorMsg;
00051 }
00052 clException (const std::string &strErrorMsg, int iErrorCode)
00053 throw()
00054 {
00055 iCode = iErrorCode;
00056 strMsg = strErrorMsg;
00057 }
00058 clException (const char *cpErrorMsg) throw()
00059 {
00060 iCode = 0;
00061 strMsg = std::string(cpErrorMsg);
00062 }
00063 clException (const char *cpErrorMsg, int iErrorCode) throw()
00064 {
00065 iCode = iErrorCode;
00066 strMsg = std::string(cpErrorMsg);
00067 }
00068 virtual ~clException () throw()
00069 { }
00070 operator int () const throw()
00071 {
00072 return iCode;
00073 }
00074 operator std::string () const throw()
00075 {
00076 return strMsg;
00077 }
00078 virtual const char * what () const throw()
00079 {
00080 return strMsg.c_str();
00081 }
00082 };
00083
00084
00085 #endif