00001 #ifndef __QpidError__
00002 #define __QpidError__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <string>
00024 #include <memory>
00025 #include <ostream>
00026
00027 #include "Exception.h"
00028
00029 namespace qpid {
00030
00031 struct SrcLine {
00032 public:
00033 SrcLine(const std::string& file_="", int line_=0) :
00034 file(file_), line(line_) {}
00035
00036 std::string file;
00037 int line;
00038 };
00039
00040 class QpidError : public Exception
00041 {
00042 public:
00043 const int code;
00044 SrcLine loc;
00045 std::string msg;
00046
00047 QpidError();
00048
00049 template <class T>
00050 QpidError(int code_, const T& msg_, const SrcLine& loc_) throw()
00051 : code(code_), loc(loc_), msg(boost::lexical_cast<std::string>(msg_))
00052 { init(); }
00053
00054 ~QpidError() throw();
00055 Exception* clone() const throw();
00056 void throwSelf() const;
00057
00058 private:
00059
00060 void init();
00061 };
00062
00063
00064 }
00065
00066 #define SRCLINE ::qpid::SrcLine(__FILE__, __LINE__)
00067
00068 #define QPID_ERROR(CODE, MESSAGE) ::qpid::QpidError((CODE), (MESSAGE), SRCLINE)
00069
00070 #define THROW_QPID_ERROR(CODE, MESSAGE) throw QPID_ERROR(CODE,MESSAGE)
00071
00072 const int PROTOCOL_ERROR = 10000;
00073 const int APR_ERROR = 20000;
00074 const int FRAMING_ERROR = 30000;
00075 const int CLIENT_ERROR = 40000;
00076 const int INTERNAL_ERROR = 50000;
00077
00078 #endif