00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef IXLIB_EXBASE
00011 #define IXLIB_EXBASE
00012
00013
00014
00015
00016 #include <stdexcept>
00017 #include <ixlib_base.hh>
00018
00019
00020
00021
00022
00023 #define EX_INFOMAX 255
00024
00025
00026
00027
00028
00029 #define EX_THROW(TYPE,CODE)\
00030 throw ::ixion::TYPE##_exception(CODE,NULL,__FILE__,__LINE__);
00031 #define EX_THROWINFO(TYPE,CODE,INFO)\
00032 throw ::ixion::TYPE##_exception(CODE,(char const *) INFO,__FILE__,__LINE__);
00033 #define EX_CATCHCODE(TYPE,CODE,HANDLER)\
00034 catch (TYPE##_exception &ex) { \
00035 if (ex.Error != CODE) throw; \
00036 HANDLER \
00037 }
00038 #define EX_CONVERT(TYPE,CODE,DESTTYPE,DESTCODE)\
00039 catch (TYPE##_exception &ex) { \
00040 if (ex.Error != CODE) throw; \
00041 throw DESTTYPE##_exception(DESTCODE,ex.Info,__FILE__,__LINE__); \
00042 }
00043
00044
00045
00046
00047
00048 namespace ixion {
00049 typedef unsigned int TErrorCode;
00050
00051
00052
00053
00054 struct base_exception : public std::exception {
00055 TErrorCode Error;
00056 char *Module;
00057 TIndex Line;
00058 char *Category;
00059 bool HasInfo;
00060 char Info[EX_INFOMAX+1];
00061 static char RenderBuffer[EX_INFOMAX+1+100];
00062
00063 base_exception(TErrorCode error,char const *info = NULL,char *module = NULL,
00064 TIndex line = 0,char *category = NULL);
00065 char const *what() const throw ();
00066 virtual const char *getText() const = 0;
00067 };
00068 }
00069
00070
00071
00072 #endif