25 #ifndef __AMPSEXCEPTION_HPP_
26 #define __AMPSEXCEPTION_HPP_
27 #define _AMPS_SKIP_AMPSPLUSPLUS
29 #undef _AMPS_SKIP_AMPSPLUSPLUS
52 : std::runtime_error(message_),
65 : std::runtime_error(
""),
71 buffer[
sizeof(buffer) - 1] =
'\0';
72 (std::runtime_error&)*
this = std::runtime_error(buffer);
92 return "AMPSException";
104 #define AMPS_EX_TYPE(x, b) \
108 x(const std::string& message, amps_result result = AMPS_E_OK)\
109 : b(message, result)\
113 x(amps_handle client, amps_result result)\
118 virtual const char* getClassName() const\
128 AMPS_EX_TYPE(ConnectionRefusedException, ConnectionException)
129 AMPS_EX_TYPE(DisconnectedException, ConnectionException)
130 AMPS_EX_TYPE(AlreadyConnectedException, ConnectionException)
131 AMPS_EX_TYPE(AuthenticationException, ConnectionException)
132 AMPS_EX_TYPE(InvalidURIException, ConnectionException)
133 AMPS_EX_TYPE(NameInUseException, ConnectionException)
134 AMPS_EX_TYPE(NotEntitledException, ConnectionException)
135 AMPS_EX_TYPE(ReconnectMaximumExceededException, ConnectionException)
136 AMPS_EX_TYPE(RetryOperationException, ConnectionException)
137 AMPS_EX_TYPE(TimedOutException, ConnectionException)
138 AMPS_EX_TYPE(TransportTypeException, ConnectionException)
139 AMPS_EX_TYPE(BadFilterException, CommandException)
140 AMPS_EX_TYPE(BadSowKeyException, CommandException)
141 AMPS_EX_TYPE(BadRegexTopicException, CommandException)
142 AMPS_EX_TYPE(DuplicateLogonException, CommandException)
143 AMPS_EX_TYPE(InvalidBookmarkException, CommandException)
144 AMPS_EX_TYPE(InvalidOptionsException, CommandException)
145 AMPS_EX_TYPE(InvalidOrderByException, CommandException)
146 AMPS_EX_TYPE(InvalidSubIdException, CommandException)
147 AMPS_EX_TYPE(InvalidTopicException, CommandException)
148 AMPS_EX_TYPE(LogonRequiredException, CommandException)
149 AMPS_EX_TYPE(MissingFieldsException, CommandException)
150 AMPS_EX_TYPE(PublishException, CommandException)
151 AMPS_EX_TYPE(SubscriptionAlreadyExistsException, CommandException)
152 AMPS_EX_TYPE(SubidInUseException, CommandException)
153 AMPS_EX_TYPE(UnknownException, CommandException)
154 AMPS_EX_TYPE(ReplayFailedException, CommandException)
155 AMPS_EX_TYPE(PublishStoreGapException, StoreException)
165 throw CommandException(context_, result_);
167 throw ConnectionException(context_, result_);
169 throw InvalidTopicException(context_, result_);
171 throw BadFilterException(context_, result_);
173 throw RetryOperationException(context_, result_);
175 throw DisconnectedException(context_, result_);
177 throw ConnectionRefusedException(context_, result_);
179 throw InvalidURIException(context_, result_);
181 throw TransportTypeException(context_, result_);
183 throw UsageException(context_, result_);
Core type and function declarations for the AMPS C client.
amps_result
Return values from amps_xxx functions.
Definition: amps.h:217
@ AMPS_E_RETRY
The operation has not succeeded, but ought to be retried.
Definition: amps.h:245
@ AMPS_E_USAGE
The usage of this function is invalid.
Definition: amps.h:269
@ AMPS_E_URI
The specified URI is invalid.
Definition: amps.h:261
@ AMPS_E_OK
Success.
Definition: amps.h:221
@ AMPS_E_DISCONNECTED
The client and server are disconnected.
Definition: amps.h:249
@ AMPS_E_COMMAND
An error with a command occurred.
Definition: amps.h:229
@ AMPS_E_TRANSPORT_TYPE
The specified transport type is invalid.
Definition: amps.h:265
@ AMPS_E_TOPIC
The specified topic was invalid.
Definition: amps.h:237
@ AMPS_E_CONNECTION_REFUSED
The server could not be found, or it actively refused our connection.
Definition: amps.h:253
@ AMPS_E_CONNECTION
A connection error occurred.
Definition: amps.h:233
@ AMPS_E_FILTER
The specified filter was invalid.
Definition: amps.h:241
AMPSDLL size_t amps_client_get_error(amps_handle client, amps_char *errorMessageOut, size_t bufferSize)
Returns the last error set on this client.
void * amps_handle
Opaque handle type used to refer to objects in the AMPS api.
Definition: amps.h:211
Base class for all exceptions in AMPS.
Definition: AMPSException.hpp:41
AMPSException(const std::string &message_, amps_result result_)
Construct an AMPSException from a text message.
Definition: AMPSException.hpp:50
const char * toString() const
Returns a null-terminated string containing self's error message.
Definition: AMPSException.hpp:80
static void throwFor(const T &context_, amps_result result_)
Constructs and throws the appropriate exception corresponding to a given result.
virtual const char * getClassName() const
Returns the actual name of the subclass thrown – useful when RTTI is disabled, but you'd still like t...
Definition: AMPSException.hpp:90
AMPSException(amps_handle client_, amps_result result_)
Construct an AMPSException from the last error message on client.
Definition: AMPSException.hpp:63