00001 #ifndef COMMONS_EXCEPTIONS_H
00002 #define COMMONS_EXCEPTIONS_H
00003
00004 #include <exception>
00005 #include <string>
00006
00007 namespace commons
00008 {
00009
00010 using namespace std;
00011
00012 class operation_not_supported : public std::exception
00013 {
00014 public:
00015 operation_not_supported(const string &op) : msg("operation not supported: " + op) {}
00016 ~operation_not_supported() throw() {}
00017 const char *what() const throw() { return msg.c_str(); }
00018 private:
00019 const string msg;
00020 };
00021
00022 class msg_exception : public std::exception
00023 {
00024 public:
00025 msg_exception(const string &msg) : msg_(msg) {}
00026 ~msg_exception() throw() {}
00027 const char *what() const throw() { return msg_.c_str(); }
00028 private:
00029 const string msg_;
00030 };
00031
00032 #define throw_operation_not_supported() throw operation_not_supported(__PRETTY_FUNCTION__)
00033
00034 }
00035
00036 #endif