exception.h Source File (original) (raw)

00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 00030 00031 00032 00033 00034 00035 00036 #ifndef MPS_Exception_H 00037 #define MPS_Exception_H 00038 00039 #include 00040 00041 namespace MPS { 00042 00043 00044 00045 class MPSException: public std::exception { 00046 private: 00047 string _message;
00048 public: 00049 MPSException() {} 00050 MPSException(string const &message) 00051 : _message(message) 00052 {} 00053 00054 string const &getMessage() const { return _message; } 00055 char const *what() const { return _message.c_str(); } 00056 }; 00057 00058 00059 00060 00061 class UserException: public MPSException { 00062 public: 00063 UserException() 00064 : MPSException("UserException thrown") 00065 {} 00066 }; 00067 00068 00069 00070 00071 class MPSConnectionClosedException: public MPSException { 00072 public: 00073 MPSConnectionClosedException() {} 00074 MPSConnectionClosedException(string const &when) 00075 : MPSException("Connection closed: " + when) 00076 {} 00077 }; 00078 00079 } 00080 00081 #endif