00001
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef OM_HGUARD_OMERROR_H
00026 #define OM_HGUARD_OMERROR_H
00027
00028 #include <string>
00029
00030 #include "om/omtypes.h"
00031
00032 class OmErrorHandler;
00033
00035
00036
00037 class OmError {
00038 friend class OmErrorHandler;
00039 private:
00041 std::string msg;
00042
00044 std::string context;
00045
00047 std::string type;
00048
00050 int errno_value;
00051
00053 bool has_been_handled;
00054
00056 void operator=(const OmError ©me);
00057 protected:
00061 OmError(const std::string &msg_,
00062 const std::string &context_,
00063 const std::string &type_,
00064 int errno_value_);
00065
00066 OmError(const OmError ©me)
00067 : msg(copyme.msg),
00068 context(copyme.context),
00069 type(copyme.type),
00070 errno_value(copyme.errno_value),
00071 has_been_handled(copyme.has_been_handled) {}
00072 public:
00076 std::string get_msg() const
00077 {
00078 return msg;
00079 }
00080
00082 std::string get_type() const
00083 {
00084 return type;
00085 }
00086
00088 std::string get_context() const
00089 {
00090 return context;
00091 }
00092
00094 int get_errno() const
00095 {
00096 return errno_value;
00097 }
00098
00100 virtual ~OmError();
00101 };
00102
00103 inline OmError::~OmError() {}
00104
00105 #define DEFINE_ERROR_BASECLASS(a, b) \
00106 class a : public b { \
00107 protected: \
00108 \
00109 a(const std::string &msg_, \
00110 const std::string &context_, \
00111 const std::string &type_, \
00112 int errno_value_) : b(msg_, context_, type_, errno_value_) {} \
00113 }
00114
00115 #define DEFINE_ERROR_CLASS(a, b) \
00116 class a : public b { \
00117 public: \
00118 \
00119 a(const std::string &msg_, \
00120 const std::string &context_ = "", \
00121 int errno_value_ = 0) : b(msg_, context_, #a, errno_value_) {} \
00122 \
00123 a(const std::string &msg_, \
00124 int errno_value_) : b(msg_, "", #a, errno_value_) {} \
00125 protected: \
00126 \
00127 a(const std::string &msg_, \
00128 const std::string &context_, \
00129 const std::string &type_, \
00130 int errno_value_) : b(msg_, context_, type_, errno_value_) {} \
00131 }
00132
00133 #include "om/omerrortypes.h"
00134
00135 #undef DEFINE_ERROR_BASECLASS
00136 #undef DEFINE_ERROR_CLASS
00137
00138 #endif