StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StMuException.hh
1 #ifndef StMuException_hh
2 #define StMuException_hh
3 
4 #include <string>
5 #include "Stiostream.h"
6 #include <typeinfo>
7 #include "StMuDebug.h"
8 
9 #ifndef ST_NO_NAMESPACES
10 using namespace std;
11 #endif
12 
13 
14 
15 enum StMuExceptionTypes {kUnknown=0, kNullPointer, kBadFlag, kBadValue, kEOF};
25 protected:
26  StMuExceptionTypes mException;
27  string mMessage;
28  string mIn;
29 public:
30  StMuException(StMuExceptionTypes=kUnknown, const char* m="", const char* in="???") : mMessage(m), mIn(in) { /* no-op */ }
31  virtual ~StMuException() {}
32  virtual string message() {return mMessage; }
33  virtual void print() { cout << "*** StMuException #" << (unsigned long)mException << " *** " << mIn << " *** " << message() << " ***" << endl; }
34  virtual StMuExceptionTypes type() { return mException; }
35 };
36 
37 
38 #define THROW(key,text) StMuException##key(text,__PRETTYF_)
39 #define EXE(x) class StMuException##x : public StMuException { public: StMuException##x (const char* m="", const char* in="???") : StMuException(k##x, m, in) { /* no-op */ } };
40 
41 
42 EXE(Unknown);
43 EXE(NullPointer);
44 EXE(BadValue);
45 EXE(BadFlag);
46 EXE(EOF);
47 
48 
49 
50 
51 
52 #endif
53