00001
00002
00003
00004 #ifndef ALCAPEXCEPT_H_
00005 #define ALCAPEXCEPT_H_
00006
00007 #include <exception>
00008 #include <string>
00009
00010 namespace Except {
00011 class Base;
00012 }
00013
00063 class Except::Base: public std::exception {
00065 char fTrace[2048];
00067 char fWhat[256];
00068
00069 public:
00071 static unsigned int gBacktraceSymbols;
00072
00073 Base();
00074 virtual ~Base() throw() {}
00075
00078 const char* what(void) const throw() {return fWhat;}
00079
00082 const char* bt(void) const throw() {return fTrace;}
00083
00086 void AppendWhat(const char* child);
00087
00090 void AppendWhat(const char* child, const char* message);
00091
00094 void AppendWhat(const char* child, const char* file, int line);
00095 };
00096
00097 #define STRINGIFY_1(x) #x
00098 #define STRINGIFY_2(x) STRINGIFY_1(x)
00099 #define LOCATION __FILE__ ":" STRINGIFY_2(__LINE__)
00100
00114 #ifndef MAKE_EXCEPTION
00115 #define MAKE_EXCEPTION(NAME, PARENT) \
00116 namespace Except { \
00117 class NAME : public PARENT { \
00118 public: \
00119 NAME() {AppendWhat(#NAME);} \
00120 NAME(const char* message) {AppendWhat(#NAME, message);} \
00121 NAME(const char* file, int line) {AppendWhat(#NAME, file, line);} \
00122 }; \
00123 }
00124 #endif //MAKE_EXCEPTION
00125 #endif //ALCAPEXCEPT_H_