19 #include <boost/uuid/nil_generator.hpp>
21 #include "hazelcast/client/exception/iexception.h"
22 #include "hazelcast/client/protocol/ClientProtocolErrorCodes.h"
24 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
26 #pragma warning(disable : 4251)
32 #define DEFINE_EXCEPTION_CLASS(ClassName, errorNo, isRuntime) \
33 class HAZELCAST_API ClassName : public iexception \
36 ClassName(std::string source, \
37 std::string message, \
38 std::string details = "", \
39 std::exception_ptr cause = nullptr, \
40 bool retryable = false) \
41 : ClassName(#ClassName, \
51 explicit ClassName(std::string message) \
52 : ClassName("", std::move(message)) \
59 ClassName(std::string errorName, \
62 std::string message, \
63 std::string details, \
64 std::exception_ptr cause, \
67 : iexception(std::move(errorName), \
81 DEFINE_EXCEPTION_CLASS(undefined_error_code, protocol::UNDEFINED,
false);
83 DEFINE_EXCEPTION_CLASS(execution, protocol::EXECUTION,
false);
85 DEFINE_EXCEPTION_CLASS(class_not_found, protocol::CLASS_NOT_FOUND,
false);
87 DEFINE_EXCEPTION_CLASS(eof, protocol::ENDOFFILE,
false);
89 DEFINE_EXCEPTION_CLASS(io, protocol::IO,
false);
91 DEFINE_EXCEPTION_CLASS(illegal_access,
92 protocol::ILLEGAL_ACCESS_EXCEPTION,
95 DEFINE_EXCEPTION_CLASS(illegal_access_error,
96 protocol::ILLEGAL_ACCESS_ERROR,
99 DEFINE_EXCEPTION_CLASS(interrupted, protocol::INTERRUPTED,
false);
101 DEFINE_EXCEPTION_CLASS(not_serializable, protocol::NOT_SERIALIZABLE,
false);
103 DEFINE_EXCEPTION_CLASS(socket, protocol::SOCK_ERROR,
false);
105 DEFINE_EXCEPTION_CLASS(timeout, protocol::TIMEOUT,
false);
106 DEFINE_EXCEPTION_CLASS(uri_syntax, protocol::URI_SYNTAX,
false);
107 DEFINE_EXCEPTION_CLASS(utf_data_format, protocol::UTF_DATA_FORMAT,
false);
108 DEFINE_EXCEPTION_CLASS(xa, protocol::XA,
false);
109 DEFINE_EXCEPTION_CLASS(login, protocol::LOGIN,
false);
110 DEFINE_EXCEPTION_CLASS(unsupported_callback,
111 protocol::UNSUPPORTED_CALLBACK,
113 DEFINE_EXCEPTION_CLASS(assertion_error, protocol::ASSERTION_ERROR,
false);
114 DEFINE_EXCEPTION_CLASS(out_of_memory_error,
115 protocol::OUT_OF_MEMORY_ERROR,
117 DEFINE_EXCEPTION_CLASS(stack_overflow_error,
118 protocol::STACK_OVERFLOW_ERROR,
120 DEFINE_EXCEPTION_CLASS(native_out_of_memory_error,
121 protocol::NATIVE_OUT_OF_MEMORY_ERROR,
126 DEFINE_EXCEPTION_CLASS(array_index_out_of_bounds,
127 protocol::INDEX_OUT_OF_BOUNDS,
129 DEFINE_EXCEPTION_CLASS(array_store, protocol::ARRAY_STORE,
true);
130 DEFINE_EXCEPTION_CLASS(authentication, protocol::AUTHENTICATION,
true);
131 DEFINE_EXCEPTION_CLASS(cache_not_exists, protocol::CACHE_NOT_EXISTS,
true);
132 DEFINE_EXCEPTION_CLASS(cancellation, protocol::CANCELLATION,
true);
133 DEFINE_EXCEPTION_CLASS(class_cast, protocol::CLASS_CAST,
true);
134 DEFINE_EXCEPTION_CLASS(concurrent_modification,
135 protocol::CONCURRENT_MODIFICATION,
137 DEFINE_EXCEPTION_CLASS(config_mismatch, protocol::CONFIG_MISMATCH,
true);
138 DEFINE_EXCEPTION_CLASS(distributed_object_destroyed,
139 protocol::DISTRIBUTED_OBJECT_DESTROYED,
141 DEFINE_EXCEPTION_CLASS(entry_processor, protocol::ENTRY_PROCESSOR,
true);
142 DEFINE_EXCEPTION_CLASS(hazelcast_, protocol::HAZELCAST,
true);
143 DEFINE_EXCEPTION_CLASS(hazelcast_instance_not_active,
144 protocol::HAZELCAST_INSTANCE_NOT_ACTIVE,
146 DEFINE_EXCEPTION_CLASS(hazelcast_overload, protocol::HAZELCAST_OVERLOAD,
true);
147 DEFINE_EXCEPTION_CLASS(hazelcast_serialization,
148 protocol::HAZELCAST_SERIALIZATION,
150 DEFINE_EXCEPTION_CLASS(illegal_argument, protocol::ILLEGAL_ARGUMENT,
true);
151 DEFINE_EXCEPTION_CLASS(illegal_monitor_state,
152 protocol::ILLEGAL_MONITOR_STATE,
154 DEFINE_EXCEPTION_CLASS(illegal_state, protocol::ILLEGAL_STATE,
true);
155 DEFINE_EXCEPTION_CLASS(illegal_thread_state,
156 protocol::ILLEGAL_THREAD_STATE,
158 DEFINE_EXCEPTION_CLASS(index_out_of_bounds,
159 protocol::INDEX_OUT_OF_BOUNDS,
161 DEFINE_EXCEPTION_CLASS(invalid_address, protocol::INVALID_ADDRESS,
true);
162 DEFINE_EXCEPTION_CLASS(invalid_configuration,
163 protocol::INVALID_CONFIGURATION,
165 DEFINE_EXCEPTION_CLASS(negative_array_size,
166 protocol::NEGATIVE_ARRAY_SIZE,
168 DEFINE_EXCEPTION_CLASS(no_such_element, protocol::NO_SUCH_ELEMENT,
true);
169 DEFINE_EXCEPTION_CLASS(null_pointer, protocol::NULL_POINTER,
true);
170 DEFINE_EXCEPTION_CLASS(operation_timeout, protocol::OPERATION_TIMEOUT,
true);
171 DEFINE_EXCEPTION_CLASS(query_result_size_exceeded,
172 protocol::QUERY_RESULT_SIZE_EXCEEDED,
174 DEFINE_EXCEPTION_CLASS(split_brain_protection,
175 protocol::SPLIT_BRAIN_PROTECTION,
177 DEFINE_EXCEPTION_CLASS(reached_max_size, protocol::REACHED_MAX_SIZE,
true);
178 DEFINE_EXCEPTION_CLASS(rejected_execution, protocol::REJECTED_EXECUTION,
true);
179 DEFINE_EXCEPTION_CLASS(response_already_sent,
180 protocol::RESPONSE_ALREADY_SENT,
182 DEFINE_EXCEPTION_CLASS(runtime, protocol::RUNTIME,
true);
183 DEFINE_EXCEPTION_CLASS(SecurityException, protocol::SECURITY,
true);
188 DEFINE_EXCEPTION_CLASS(stale_sequence, protocol::STALE_SEQUENCE,
true);
189 DEFINE_EXCEPTION_CLASS(target_disconnected,
190 protocol::TARGET_DISCONNECTED,
192 DEFINE_EXCEPTION_CLASS(topic_overload, protocol::TOPIC_OVERLOAD,
true);
194 DEFINE_EXCEPTION_CLASS(transaction, protocol::TRANSACTION,
true);
195 DEFINE_EXCEPTION_CLASS(transaction_not_active,
196 protocol::TRANSACTION_NOT_ACTIVE,
198 DEFINE_EXCEPTION_CLASS(transaction_timed_out,
199 protocol::TRANSACTION_TIMED_OUT,
201 DEFINE_EXCEPTION_CLASS(unsupported_operation,
202 protocol::UNSUPPORTED_OPERATION,
204 DEFINE_EXCEPTION_CLASS(access_control, protocol::ACCESS_CONTROL,
true);
205 DEFINE_EXCEPTION_CLASS(no_data_member_in_cluster,
206 protocol::NO_DATA_MEMBER,
208 DEFINE_EXCEPTION_CLASS(replicated_map_cant_be_created_on_lite_member,
209 protocol::REPLICATED_MAP_CANT_BE_CREATED,
211 DEFINE_EXCEPTION_CLASS(max_message_size_exceeded,
212 protocol::MAX_MESSAGE_SIZE_EXCEEDED,
214 DEFINE_EXCEPTION_CLASS(wan_replication_queue_full,
215 protocol::WAN_REPLICATION_QUEUE_FULL,
217 DEFINE_EXCEPTION_CLASS(service_not_found, protocol::SERVICE_NOT_FOUND,
true);
219 DEFINE_EXCEPTION_CLASS(stale_task_id, protocol::STALE_TASK_ID,
true);
221 DEFINE_EXCEPTION_CLASS(duplicate_task, protocol::DUPLICATE_TASK,
true);
223 DEFINE_EXCEPTION_CLASS(stale_task, protocol::STALE_TASK,
true);
225 DEFINE_EXCEPTION_CLASS(local_member_reset, protocol::LOCAL_MEMBER_RESET,
true);
227 DEFINE_EXCEPTION_CLASS(indeterminate_operation_state,
228 protocol::INDETERMINATE_OPERATION_STATE,
231 DEFINE_EXCEPTION_CLASS(node_id_out_of_range,
232 protocol::FLAKE_ID_NODE_ID_OUT_OF_RANGE_EXCEPTION,
235 DEFINE_EXCEPTION_CLASS(mutation_disallowed,
236 protocol::MUTATION_DISALLOWED_EXCEPTION,
239 DEFINE_EXCEPTION_CLASS(session_expired,
240 protocol::SESSION_EXPIRED_EXCEPTION,
243 DEFINE_EXCEPTION_CLASS(wait_key_cancelled,
244 protocol::WAIT_KEY_CANCELLED_EXCEPTION,
247 DEFINE_EXCEPTION_CLASS(lock_acquire_limit_reached,
248 protocol::LOCK_ACQUIRE_LIMIT_REACHED_EXCEPTION,
251 DEFINE_EXCEPTION_CLASS(lock_ownership_lost,
252 protocol::LOCK_OWNERSHIP_LOST_EXCEPTION,
255 DEFINE_EXCEPTION_CLASS(cp_group_destroyed,
256 protocol::CP_GROUP_DESTROYED_EXCEPTION,
259 DEFINE_EXCEPTION_CLASS(cannot_replicate,
260 protocol::CANNOT_REPLICATE_EXCEPTION,
263 DEFINE_EXCEPTION_CLASS(leader_demoted,
264 protocol::LEADER_DEMOTED_EXCEPTION,
267 DEFINE_EXCEPTION_CLASS(stale_append_request,
268 protocol::STALE_APPEND_REQUEST_EXCEPTION,
271 DEFINE_EXCEPTION_CLASS(not_leader, protocol::NOT_LEADER_EXCEPTION,
true);
273 DEFINE_EXCEPTION_CLASS(version_mismatch,
274 protocol::VERSION_MISMATCH_EXCEPTION,
285 std::exception_ptr cause,
290 std::string message =
"",
291 std::string details =
"",
292 std::exception_ptr cause =
nullptr);
295 #define DEFINE_RETRYABLE_EXCEPTION_CLASS(ClassName, errorNo) \
296 class HAZELCAST_API ClassName : public retryable_hazelcast \
299 explicit ClassName(std::string source = "", \
300 std::string message = "", \
301 std::string details = "", \
302 std::exception_ptr cause = nullptr) \
303 : retryable_hazelcast(#ClassName, \
306 std::move(message), \
307 std::move(details), \
316 DEFINE_RETRYABLE_EXCEPTION_CLASS(caller_not_member,
317 protocol::CALLER_NOT_MEMBER);
318 DEFINE_RETRYABLE_EXCEPTION_CLASS(partition_migrating,
319 protocol::PARTITION_MIGRATING);
320 DEFINE_RETRYABLE_EXCEPTION_CLASS(retryable_io, protocol::RETRYABLE_IO);
321 DEFINE_RETRYABLE_EXCEPTION_CLASS(target_not_member,
322 protocol::TARGET_NOT_MEMBER);
323 DEFINE_RETRYABLE_EXCEPTION_CLASS(wrong_target, protocol::WRONG_TARGET);
325 DEFINE_RETRYABLE_EXCEPTION_CLASS(target_not_replica,
326 protocol::TARGET_NOT_REPLICA_EXCEPTION);
328 class HAZELCAST_API
query :
public hazelcast_
331 explicit query(std::string source =
"",
332 std::string message =
"",
333 std::string details =
"",
334 std::exception_ptr cause =
nullptr);
338 std::exception_ptr cause =
nullptr,
339 boost::uuids::uuid originating_member_id = boost::uuids::nil_uuid(),
340 std::string suggestion =
"");
342 int32_t code()
const;
344 const std::string& suggestion()
const;
346 const boost::uuids::uuid& originating_member_uuid()
const;
350 std::string suggestion_;
351 boost::uuids::uuid originating_member_uuid_;
358 std::string message =
"",
359 std::string details =
"",
360 std::exception_ptr cause =
nullptr);
374 std::string message =
"",
375 std::string details =
"",
376 std::exception_ptr cause =
nullptr);
379 DEFINE_EXCEPTION_CLASS(hazelcast_client_not_active,
380 protocol::HAZELCAST_INSTANCE_NOT_ACTIVE,
383 DEFINE_EXCEPTION_CLASS(hazelcast_client_offline,
384 protocol::HAZELCAST_CLIENT_OFFLINE,
395 DEFINE_EXCEPTION_CLASS(unknown_host, protocol::UNKNOWN_HOST,
false);
397 DEFINE_EXCEPTION_CLASS(client_not_allowed_in_cluster,
398 protocol::CLIENT_NOT_ALLOWED_IN_CLUSTER,
409 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)