00001
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef XAPIAN_INCLUDED_ERROR_H
00022 #define XAPIAN_INCLUDED_ERROR_H
00023
00024 #include <string>
00025
00026 namespace Xapian {
00027
00028 class ErrorHandler;
00029
00035 class Error {
00036
00037 friend class ErrorHandler;
00038
00040 std::string msg;
00041
00049 std::string context;
00050
00052 const char * type;
00053
00061 int my_errno;
00062
00064 bool already_handled;
00065
00067 void operator=(const Error &o);
00068
00069 protected:
00073 Error(const std::string &msg_, const std::string &context_,
00074 const char * type_, int errno_)
00075 : msg(msg_), context(context_), type(type_), my_errno(errno_),
00076 already_handled(false) { }
00077
00078 public:
00080 std::string get_type() const { return std::string(type); }
00081
00083 const std::string & get_msg() const { return msg; }
00084
00092 const std::string & get_context() const { return context; }
00093
00098 int get_errno() const { return my_errno; }
00099 };
00100
00101
00102
00103
00104
00105 #if defined(SWIGEXPORT) && defined(__GNUC__) && (__GNUC__ >= 4)
00106 # define XAPIAN_EXCEPTION_EXPORT SWIGEXPORT
00107 #else
00108 # define XAPIAN_EXCEPTION_EXPORT
00109 #endif
00110
00112 #define XAPIAN_DEFINE_ERROR_BASECLASS(CLASS, PARENT) \
00113 class XAPIAN_EXCEPTION_EXPORT CLASS : public PARENT { \
00114 protected: \
00115 \
00116 CLASS(const std::string &msg_, const std::string &context_, \
00117 const char * type_, int errno_) \
00118 : PARENT(msg_, context_, type_, errno_) {} \
00119 }
00120
00122 #define XAPIAN_DEFINE_ERROR_CLASS(CLASS, PARENT) \
00123 class XAPIAN_EXCEPTION_EXPORT CLASS : public PARENT { \
00124 public: \
00125 \
00126 CLASS(const std::string &msg_, const std::string &context_ = "", \
00127 int errno_ = 0) \
00128 : PARENT(msg_, context_, #CLASS, errno_) {} \
00129 \
00130 CLASS(const std::string &msg_, int errno_) \
00131 : PARENT(msg_, "", #CLASS, errno_) {} \
00132 protected: \
00133 \
00134 CLASS(const std::string &msg_, const std::string &context_, \
00135 const char * type_, int errno_) \
00136 : PARENT(msg_, context_, type_, errno_) {} \
00137 }
00138
00139 #include <xapian/errortypes.h>
00140
00141 #undef XAPIAN_DEFINE_ERROR_BASECLASS
00142 #undef XAPIAN_DEFINE_ERROR_CLASS
00143 #undef XAPIAN_EXCEPTION_EXPORT
00144
00145 }
00146
00147 #endif