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