00001 #ifndef StMuException_hh
00002 #define StMuException_hh
00003
00004 #include <string>
00005 #include "Stiostream.h"
00006 #include <typeinfo>
00007 #include "StMuDebug.h"
00008
00009 #ifndef ST_NO_NAMESPACES
00010 using namespace std;
00011 #endif
00012
00013
00014
00015 enum StMuExceptionTypes {kUnknown=0, kNullPointer, kBadFlag, kBadValue, kEOF};
00024 class StMuException {
00025 protected:
00026 StMuExceptionTypes mException;
00027 string mMessage;
00028 string mIn;
00029 public:
00030 StMuException(StMuExceptionTypes=kUnknown, const char* m="", const char* in="???") : mMessage(m), mIn(in) { }
00031 virtual ~StMuException() {}
00032 virtual string message() {return mMessage; }
00033 virtual void print() { cout << "*** StMuException #" << (unsigned long)mException << " *** " << mIn << " *** " << message() << " ***" << endl; }
00034 virtual StMuExceptionTypes type() { return mException; }
00035 };
00036
00037
00038 #define THROW(key,text) StMuException##key(text,__PRETTYF_)
00039 #define EXE(x) class StMuException##x : public StMuException { public: StMuException##x (const char* m="", const char* in="???") : StMuException(k##x, m, in) { } };
00040
00041
00042 EXE(Unknown);
00043 EXE(NullPointer);
00044 EXE(BadValue);
00045 EXE(BadFlag);
00046 EXE(EOF);
00047
00048
00049
00050
00051
00052 #endif
00053