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 class HxException : public exception, public BaseClass, public CounterConstDestr<HxException>
00046 {
00047 public:
00048 HxException();
00049 HxException(const std::string& msg, const char *file,
00050 const int line, const int ErrCode = HX_EXC_INTERNAL_ERROR);
00051 HxException(const HxException& Exc);
00052 HxException(const exception& Exc);
00053 HxException& operator=(const HxException& Exc);
00054
00055 ~HxException();
00056 virtual const char* what() const;
00057
00058 private:
00059 std::string Str;
00060 int ErrCode;
00061
00062 friend HxException AddMess(const exception& Exc, const std::string& msg);
00063 friend HxException AddMess(const exception& Exc,
00064 const std::string& filename, const int line);
00065
00066
00067 };
00068
00069
00070 #endif
00071