00001 #ifndef EXCEPTION_H_ 00002 #define EXCEPTION_H_ 00003 00004 #include "makestring.h" 00005 00006 namespace PCSIM 00007 { 00008 00009 class Exception 00010 { 00011 public: 00012 Exception( string method, string msg ) : _method(method), _MSG( msg ) {}; 00013 virtual ~Exception() {}; 00014 string message() const; 00015 virtual string name() const { return string("PCSIM::Exception"); }; 00016 protected: 00017 string _method; 00018 string _MSG; 00019 }; 00020 00021 class ConstructionException : public PCSIM::Exception 00022 { 00023 public: 00024 ConstructionException( string method, string msg ) : Exception( method, msg ) {}; 00025 virtual string name() const { return string("PCSIM::ConstructionException"); }; 00026 }; 00027 00028 class NotFoundException : public PCSIM::Exception 00029 { 00030 public: 00031 NotFoundException( string method, string msg ) : Exception( method, msg ) {}; 00032 virtual string name() const { return string("PCSIM::NotFoundException"); }; 00033 }; 00034 00035 } 00036 00037 inline string PCSIM::Exception::message() const 00038 { 00039 return name() + " in function " + _method + ": " + _MSG; 00040 } 00041 00042 #endif /*EXCEPTION_H_*/