00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef HxException_h
00017 #define HxException_h
00018
00019 #define HX_EXC_INTERNAL_ERROR (-1001)
00020 #define HX_EXC_FILE_IO (-1002)
00021
00022 #include <exception>
00023 #include <string>
00024 #include "BaseClass.h"
00025 #include "CounterConstDestr.h"
00026
00027 #ifdef HXTRYCATCH
00028 #define HXCATCH catch(exception& E) { \
00029 throw AddMess(E,__FILE__,__LINE__); \
00030 } catch(...) { \
00031 throw HxException(" ",__FILE__,__LINE__); \
00032 }
00033 #define HXCATCHPRINT catch(exception& E) { \
00034 std::cerr << E.what() << std::endl; \
00035 } catch(...) { \
00036 std::cerr << "Exit by unknown Exception." << std::endl; \
00037 }
00038 #define HXTRY try
00039 #else
00040 #define HXCATCH
00041 #define HXCATCHPRINT
00042 #define HXTRY
00043 #endif
00044
00045 using std::exception;
00046
00047 class HxException : public exception, public BaseClass, public CounterConstDestr<HxException>
00048 {
00049 public:
00050 HxException();
00051 HxException(const std::string& msg, const char *file,
00052 const int line, const int ErrCode = HX_EXC_INTERNAL_ERROR);
00053 HxException(const HxException& Exc);
00054 HxException(const exception& Exc);
00055 HxException& operator=(const HxException& Exc);
00056
00057 virtual ~HxException() throw();
00058 virtual const char* what() const throw();
00059
00060 private:
00061 std::string Str;
00062 int ErrCode;
00063
00064 friend HxException AddMess(const exception& Exc, const std::string& msg);
00065 friend HxException AddMess(const exception& Exc,
00066 const std::string& filename, const int line);
00067
00068
00069 };
00070
00071
00072 #endif
00073