Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET | Apache Qpid Documentation |
00001 #ifndef _Exception_ 00002 #define _Exception_ 00003 00004 /* 00005 * 00006 * Licensed to the Apache Software Foundation (ASF) under one 00007 * or more contributor license agreements. See the NOTICE file 00008 * distributed with this work for additional information 00009 * regarding copyright ownership. The ASF licenses this file 00010 * to you under the Apache License, Version 2.0 (the 00011 * "License"); you may not use this file except in compliance 00012 * with the License. You may obtain a copy of the License at 00013 * 00014 * http://www.apache.org/licenses/LICENSE-2.0 00015 * 00016 * Unless required by applicable law or agreed to in writing, 00017 * software distributed under the License is distributed on an 00018 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 00019 * KIND, either express or implied. See the License for the 00020 * specific language governing permissions and limitations 00021 * under the License. 00022 * 00023 */ 00024 00025 #include "qpid/framing/amqp_types.h" 00026 #include "qpid/framing/constants.h" 00027 #include "qpid/framing/enum.h" 00028 #include "qpid/sys/StrError.h" 00029 #include "qpid/Msg.h" 00030 #include "qpid/CommonImportExport.h" 00031 #include <memory> 00032 #include <string> 00033 #include <errno.h> 00034 00035 namespace qpid 00036 { 00037 00041 class Exception : public std::exception 00042 { 00043 public: 00044 QPID_COMMON_EXTERN explicit Exception(const std::string& message=std::string()) throw(); 00045 QPID_COMMON_EXTERN virtual ~Exception() throw(); 00046 QPID_COMMON_EXTERN virtual const char* what() const throw(); // prefix: message 00047 QPID_COMMON_EXTERN virtual std::string getMessage() const; // Unprefixed message 00048 QPID_COMMON_EXTERN virtual std::string getPrefix() const; // Prefix 00049 00050 private: 00051 std::string message; 00052 mutable std::string whatStr; 00053 }; 00054 00056 struct ErrnoException : public Exception { 00057 ErrnoException(const std::string& msg, int err) : Exception(msg+": "+qpid::sys::strError(err)) {} 00058 ErrnoException(const std::string& msg) : Exception(msg+": "+qpid::sys::strError(errno)) {} 00059 }; 00060 00061 struct SessionException : public Exception { 00062 const framing::execution::ErrorCode code; 00063 SessionException(framing::execution::ErrorCode code_, const std::string& message) 00064 : Exception(message), code(code_) {} 00065 }; 00066 00067 struct ChannelException : public Exception { 00068 const framing::session::DetachCode code; 00069 ChannelException(framing::session::DetachCode _code, const std::string& message) 00070 : Exception(message), code(_code) {} 00071 }; 00072 00073 struct ConnectionException : public Exception { 00074 const framing::connection::CloseCode code; 00075 ConnectionException(framing::connection::CloseCode _code, const std::string& message) 00076 : Exception(message), code(_code) {} 00077 }; 00078 00079 struct ClosedException : public Exception { 00080 QPID_COMMON_EXTERN ClosedException(const std::string& msg=std::string()); 00081 QPID_COMMON_EXTERN std::string getPrefix() const; 00082 }; 00083 00087 struct TransportFailure : public Exception { 00088 TransportFailure(const std::string& msg=std::string()) : Exception(msg) {} 00089 }; 00090 00091 } // namespace qpid 00092 00093 #endif