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/CommonImportExport.h" 00030 #include <string> 00031 #include <errno.h> 00032 00033 namespace qpid 00034 { 00035 00039 class Exception : public std::exception 00040 { 00041 public: 00042 QPID_COMMON_EXTERN explicit Exception(const std::string& message=std::string()) throw(); 00043 QPID_COMMON_EXTERN virtual ~Exception() throw(); 00044 QPID_COMMON_EXTERN virtual const char* what() const throw(); // prefix: message 00045 QPID_COMMON_EXTERN virtual std::string getMessage() const; // Unprefixed message 00046 QPID_COMMON_EXTERN virtual std::string getPrefix() const; // Prefix 00047 00048 private: 00049 std::string message; 00050 mutable std::string whatStr; 00051 }; 00052 00054 struct ErrnoException : public Exception { 00055 ErrnoException(const std::string& msg, int err) : Exception(msg+": "+qpid::sys::strError(err)) {} 00056 ErrnoException(const std::string& msg) : Exception(msg+": "+qpid::sys::strError(errno)) {} 00057 }; 00058 00059 struct SessionException : public Exception { 00060 const framing::execution::ErrorCode code; 00061 SessionException(framing::execution::ErrorCode code_, const std::string& message) 00062 : Exception(message), code(code_) {} 00063 }; 00064 00065 struct ChannelException : public Exception { 00066 const framing::session::DetachCode code; 00067 ChannelException(framing::session::DetachCode _code, const std::string& message) 00068 : Exception(message), code(_code) {} 00069 }; 00070 00071 struct ConnectionException : public Exception { 00072 const framing::connection::CloseCode code; 00073 ConnectionException(framing::connection::CloseCode _code, const std::string& message) 00074 : Exception(message), code(_code) {} 00075 }; 00076 00077 struct ClosedException : public Exception { 00078 QPID_COMMON_EXTERN ClosedException(const std::string& msg=std::string()); 00079 QPID_COMMON_EXTERN std::string getPrefix() const; 00080 }; 00081 00085 struct TransportFailure : public Exception { 00086 TransportFailure(const std::string& msg=std::string()) : Exception(msg) {} 00087 }; 00088 00089 } // namespace qpid 00090 00091 #endif