00001 #ifndef _Exception_
00002 #define _Exception_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "qpid/framing/amqp_types.h"
00026 #include "qpid/framing/constants.h"
00027 #include "qpid/sys/StrError.h"
00028 #include "qpid/Msg.h"
00029
00030 #include <memory>
00031 #include <string>
00032 #include <errno.h>
00033
00034 namespace qpid
00035 {
00036
00040 class Exception : public std::exception
00041 {
00042 public:
00043 explicit Exception(const std::string& message=std::string()) throw();
00044 virtual ~Exception() throw();
00045 virtual const char* what() const throw();
00046 virtual std::string getMessage() const;
00047 virtual std::string getPrefix() const;
00048
00049 private:
00050 std::string message;
00051 mutable std::string whatStr;
00052 };
00053
00055 struct ErrnoException : public Exception {
00056 ErrnoException(const std::string& msg, int err) : Exception(msg+": "+qpid::sys::strError(err)) {}
00057 ErrnoException(const std::string& msg) : Exception(msg+": "+qpid::sys::strError(errno)) {}
00058 };
00059
00060 struct SessionException : public Exception {
00061 const framing::ReplyCode code;
00062 SessionException(framing::ReplyCode code_, const std::string& message)
00063 : Exception(message), code(code_) {}
00064 };
00065
00066 struct ChannelException : public Exception {
00067 const framing::ReplyCode code;
00068 ChannelException(framing::ReplyCode _code, const std::string& message)
00069 : Exception(message), code(_code) {}
00070 };
00071
00072 struct ConnectionException : public Exception {
00073 const framing::ReplyCode code;
00074 ConnectionException(framing::ReplyCode _code, const std::string& message)
00075 : Exception(message), code(_code) {}
00076 };
00077
00078 struct ClosedException : public Exception {
00079 ClosedException(const std::string& msg=std::string());
00080 std::string getPrefix() const;
00081 };
00082
00083 }
00084
00085 #endif