| 1 |
#ifndef QPID_MESSAGING_EXCEPTIONS_H |
| 2 |
#define QPID_MESSAGING_EXCEPTIONS_H |
| 3 |
|
| 4 |
/* |
| 5 |
* |
| 6 |
* Licensed to the Apache Software Foundation (ASF) under one |
| 7 |
* or more contributor license agreements. See the NOTICE file |
| 8 |
* distributed with this work for additional information |
| 9 |
* regarding copyright ownership. The ASF licenses this file |
| 10 |
* to you under the Apache License, Version 2.0 (the |
| 11 |
* "License"); you may not use this file except in compliance |
| 12 |
* with the License. You may obtain a copy of the License at |
| 13 |
* |
| 14 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 15 |
* |
| 16 |
* Unless required by applicable law or agreed to in writing, |
| 17 |
* software distributed under the License is distributed on an |
| 18 |
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 19 |
* KIND, either express or implied. See the License for the |
| 20 |
* specific language governing permissions and limitations |
| 21 |
* under the License. |
| 22 |
* |
| 23 |
*/ |
| 24 |
|
| 25 |
#include "qpid/messaging/ImportExport.h" |
| 26 |
#include "qpid/types/Exception.h" |
| 27 |
#include "qpid/types/Variant.h" |
| 28 |
|
| 29 |
namespace qpid { |
| 30 |
namespace messaging { |
| 31 |
|
| 32 |
/** \ingroup messaging |
| 33 |
*/ |
| 34 |
|
| 35 |
/** |
| 36 |
* This is the base class for all messaging related exceptions thrown |
| 37 |
* by this API. |
| 38 |
*/ |
| 39 |
struct QPID_MESSAGING_CLASS_EXTERN MessagingException : public qpid::types::Exception |
| 40 |
{ |
| 41 |
QPID_MESSAGING_EXTERN MessagingException(const std::string& msg); |
| 42 |
QPID_MESSAGING_EXTERN virtual ~MessagingException() throw(); |
| 43 |
|
| 44 |
qpid::types::Variant::Map detail; |
| 45 |
//TODO: override what() to include detail if present |
| 46 |
}; |
| 47 |
|
| 48 |
/** |
| 49 |
* Thrown when the syntax of the option string used to configure a |
| 50 |
* connection in not valid |
| 51 |
*/ |
| 52 |
struct QPID_MESSAGING_CLASS_EXTERN InvalidOptionString : public MessagingException |
| 53 |
{ |
| 54 |
QPID_MESSAGING_EXTERN InvalidOptionString(const std::string& msg); |
| 55 |
}; |
| 56 |
|
| 57 |
/** |
| 58 |
* Thrown to indicate a failed lookup of some local object. For |
| 59 |
* example when attempting to retrieve a session, sender or receiver |
| 60 |
* by name. |
| 61 |
*/ |
| 62 |
struct QPID_MESSAGING_CLASS_EXTERN KeyError : public MessagingException |
| 63 |
{ |
| 64 |
QPID_MESSAGING_EXTERN KeyError(const std::string&); |
| 65 |
}; |
| 66 |
|
| 67 |
struct QPID_MESSAGING_CLASS_EXTERN LinkError : public MessagingException |
| 68 |
{ |
| 69 |
QPID_MESSAGING_EXTERN LinkError(const std::string&); |
| 70 |
}; |
| 71 |
|
| 72 |
struct QPID_MESSAGING_CLASS_EXTERN AddressError : public LinkError |
| 73 |
{ |
| 74 |
QPID_MESSAGING_EXTERN AddressError(const std::string&); |
| 75 |
}; |
| 76 |
|
| 77 |
/** |
| 78 |
* Thrown when a syntactically correct address cannot be resolved or |
| 79 |
* used. |
| 80 |
*/ |
| 81 |
struct QPID_MESSAGING_CLASS_EXTERN ResolutionError : public AddressError |
| 82 |
{ |
| 83 |
QPID_MESSAGING_EXTERN ResolutionError(const std::string& msg); |
| 84 |
}; |
| 85 |
|
| 86 |
/** |
| 87 |
* Thrown when creating a sender or receiver for an address for which |
| 88 |
* some asserted property of the node is not matched. |
| 89 |
*/ |
| 90 |
struct QPID_MESSAGING_CLASS_EXTERN AssertionFailed : public ResolutionError |
| 91 |
{ |
| 92 |
QPID_MESSAGING_EXTERN AssertionFailed(const std::string& msg); |
| 93 |
}; |
| 94 |
|
| 95 |
/** |
| 96 |
* Thrown on attempts to create a sender or receiver to a non-existent |
| 97 |
* node. |
| 98 |
*/ |
| 99 |
struct QPID_MESSAGING_CLASS_EXTERN NotFound : public ResolutionError |
| 100 |
{ |
| 101 |
QPID_MESSAGING_EXTERN NotFound(const std::string& msg); |
| 102 |
}; |
| 103 |
|
| 104 |
/** |
| 105 |
* Thrown when an address string with invalid syntax is used. |
| 106 |
*/ |
| 107 |
struct QPID_MESSAGING_CLASS_EXTERN MalformedAddress : public AddressError |
| 108 |
{ |
| 109 |
QPID_MESSAGING_EXTERN MalformedAddress(const std::string& msg); |
| 110 |
}; |
| 111 |
|
| 112 |
struct QPID_MESSAGING_CLASS_EXTERN ReceiverError : public LinkError |
| 113 |
{ |
| 114 |
QPID_MESSAGING_EXTERN ReceiverError(const std::string&); |
| 115 |
}; |
| 116 |
|
| 117 |
struct QPID_MESSAGING_CLASS_EXTERN FetchError : public ReceiverError |
| 118 |
{ |
| 119 |
QPID_MESSAGING_EXTERN FetchError(const std::string&); |
| 120 |
}; |
| 121 |
|
| 122 |
/** |
| 123 |
* Thrown by Receiver::fetch(), Receiver::get() and |
| 124 |
* Session::nextReceiver() to indicate that there no message was |
| 125 |
* available before the timeout specified. |
| 126 |
*/ |
| 127 |
struct QPID_MESSAGING_CLASS_EXTERN NoMessageAvailable : public FetchError |
| 128 |
{ |
| 129 |
QPID_MESSAGING_EXTERN NoMessageAvailable(); |
| 130 |
}; |
| 131 |
|
| 132 |
struct QPID_MESSAGING_CLASS_EXTERN SenderError : public LinkError |
| 133 |
{ |
| 134 |
QPID_MESSAGING_EXTERN SenderError(const std::string&); |
| 135 |
}; |
| 136 |
|
| 137 |
struct QPID_MESSAGING_CLASS_EXTERN SendError : public SenderError |
| 138 |
{ |
| 139 |
QPID_MESSAGING_EXTERN SendError(const std::string&); |
| 140 |
}; |
| 141 |
|
| 142 |
/** |
| 143 |
* Thrown to indicate that the sender attempted to send a message that |
| 144 |
* would result in the target node on the peer exceeding a |
| 145 |
* preconfigured capacity. |
| 146 |
*/ |
| 147 |
struct QPID_MESSAGING_CLASS_EXTERN TargetCapacityExceeded : public SendError |
| 148 |
{ |
| 149 |
QPID_MESSAGING_EXTERN TargetCapacityExceeded(const std::string&); |
| 150 |
}; |
| 151 |
|
| 152 |
struct QPID_MESSAGING_CLASS_EXTERN SessionError : public MessagingException |
| 153 |
{ |
| 154 |
QPID_MESSAGING_EXTERN SessionError(const std::string&); |
| 155 |
}; |
| 156 |
|
| 157 |
struct QPID_MESSAGING_CLASS_EXTERN TransactionError : public SessionError |
| 158 |
{ |
| 159 |
QPID_MESSAGING_EXTERN TransactionError(const std::string&); |
| 160 |
}; |
| 161 |
|
| 162 |
/** |
| 163 |
* Thrown on Session::commit() if reconnection results in the |
| 164 |
* transaction being automatically aborted. |
| 165 |
*/ |
| 166 |
struct QPID_MESSAGING_CLASS_EXTERN TransactionAborted : public TransactionError |
| 167 |
{ |
| 168 |
QPID_MESSAGING_EXTERN TransactionAborted(const std::string&); |
| 169 |
}; |
| 170 |
|
| 171 |
/** |
| 172 |
* Thrown to indicate that the application attempted to do something |
| 173 |
* for which it was not authorised by its peer. |
| 174 |
*/ |
| 175 |
struct QPID_MESSAGING_CLASS_EXTERN UnauthorizedAccess : public SessionError |
| 176 |
{ |
| 177 |
QPID_MESSAGING_EXTERN UnauthorizedAccess(const std::string&); |
| 178 |
}; |
| 179 |
|
| 180 |
struct QPID_MESSAGING_CLASS_EXTERN ConnectionError : public MessagingException |
| 181 |
{ |
| 182 |
QPID_MESSAGING_EXTERN ConnectionError(const std::string&); |
| 183 |
}; |
| 184 |
|
| 185 |
/** |
| 186 |
* Thrown to indicate loss of underlying connection. When |
| 187 |
* auto-reconnect is used this will be caught by the library and used |
| 188 |
* to trigger reconnection attempts. If reconnection fails (according |
| 189 |
* to whatever settings have been configured), then an instnace of |
| 190 |
* this class will be thrown to signal that. |
| 191 |
*/ |
| 192 |
struct QPID_MESSAGING_CLASS_EXTERN TransportFailure : public MessagingException |
| 193 |
{ |
| 194 |
QPID_MESSAGING_EXTERN TransportFailure(const std::string&); |
| 195 |
}; |
| 196 |
|
| 197 |
}} // namespace qpid::messaging |
| 198 |
|
| 199 |
#endif /*!QPID_MESSAGING_EXCEPTIONS_H*/ |