19 #include "hazelcast/client/exception/iexception.h"
20 #include "hazelcast/client/protocol/ClientProtocolErrorCodes.h"
22 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
24 #pragma warning(disable: 4251)
30 #define DEFINE_EXCEPTION_CLASS(ClassName, errorNo, isRuntime) \
31 class HAZELCAST_API ClassName : public iexception {\
33 ClassName(const std::string& source, const std::string& message, \
34 const std::string& details = "", std::exception_ptr cause = nullptr, bool retryable = false) \
35 : ClassName(#ClassName, errorNo, source, message, details, cause, isRuntime, retryable) {}\
36 explicit ClassName(const std::string& message) : ClassName("", message) {}\
37 ClassName() : ClassName("", "") {}\
38 ClassName(const std::string& errorName, int32_t errorCode, const std::string& source, const std::string& message, \
39 const std::string& details, std::exception_ptr cause, bool runtime, bool retryable) \
40 : iexception(errorName, source, message, details, errorCode, cause, runtime, retryable) {}\
44 DEFINE_EXCEPTION_CLASS(undefined_error_code , protocol::UNDEFINED,
false);
46 DEFINE_EXCEPTION_CLASS(execution , protocol::EXECUTION,
false);
48 DEFINE_EXCEPTION_CLASS(class_not_found , protocol::CLASS_NOT_FOUND,
false);
50 DEFINE_EXCEPTION_CLASS(eof , protocol::ENDOFFILE,
false);
52 DEFINE_EXCEPTION_CLASS(io , protocol::IO,
false);
54 DEFINE_EXCEPTION_CLASS(illegal_access , protocol::ILLEGAL_ACCESS_EXCEPTION,
false);
56 DEFINE_EXCEPTION_CLASS(illegal_access_error, protocol::ILLEGAL_ACCESS_ERROR,
false);
58 DEFINE_EXCEPTION_CLASS(interrupted , protocol::INTERRUPTED,
false);
60 DEFINE_EXCEPTION_CLASS(not_serializable , protocol::NOT_SERIALIZABLE,
false);
62 DEFINE_EXCEPTION_CLASS(socket , protocol::SOCK_ERROR,
false);
64 DEFINE_EXCEPTION_CLASS(timeout , protocol::TIMEOUT,
false);
65 DEFINE_EXCEPTION_CLASS(uri_syntax , protocol::URI_SYNTAX,
false);
66 DEFINE_EXCEPTION_CLASS(utf_data_format , protocol::UTF_DATA_FORMAT,
false);
67 DEFINE_EXCEPTION_CLASS(xa , protocol::XA,
false);
68 DEFINE_EXCEPTION_CLASS(login , protocol::LOGIN,
false);
69 DEFINE_EXCEPTION_CLASS(unsupported_callback , protocol::UNSUPPORTED_CALLBACK,
false);
70 DEFINE_EXCEPTION_CLASS(assertion_error, protocol::ASSERTION_ERROR,
false);
71 DEFINE_EXCEPTION_CLASS(out_of_memory_error, protocol::OUT_OF_MEMORY_ERROR,
false);
72 DEFINE_EXCEPTION_CLASS(stack_overflow_error, protocol::STACK_OVERFLOW_ERROR,
false);
73 DEFINE_EXCEPTION_CLASS(native_out_of_memory_error, protocol::NATIVE_OUT_OF_MEMORY_ERROR,
false);
77 DEFINE_EXCEPTION_CLASS(array_index_out_of_bounds , protocol::INDEX_OUT_OF_BOUNDS,
true);
78 DEFINE_EXCEPTION_CLASS(array_store , protocol::ARRAY_STORE,
true);
79 DEFINE_EXCEPTION_CLASS(authentication , protocol::AUTHENTICATION,
true);
80 DEFINE_EXCEPTION_CLASS(cache_not_exists , protocol::CACHE_NOT_EXISTS,
true);
81 DEFINE_EXCEPTION_CLASS(cancellation , protocol::CANCELLATION,
true);
82 DEFINE_EXCEPTION_CLASS(class_cast , protocol::CLASS_CAST,
true);
83 DEFINE_EXCEPTION_CLASS(concurrent_modification , protocol::CONCURRENT_MODIFICATION,
true);
84 DEFINE_EXCEPTION_CLASS(config_mismatch , protocol::CONFIG_MISMATCH,
true);
85 DEFINE_EXCEPTION_CLASS(distributed_object_destroyed , protocol::DISTRIBUTED_OBJECT_DESTROYED,
true);
86 DEFINE_EXCEPTION_CLASS(entry_processor , protocol::ENTRY_PROCESSOR,
true);
87 DEFINE_EXCEPTION_CLASS(hazelcast_, protocol::HAZELCAST,
true);
88 DEFINE_EXCEPTION_CLASS(hazelcast_instance_not_active , protocol::HAZELCAST_INSTANCE_NOT_ACTIVE,
true);
89 DEFINE_EXCEPTION_CLASS(hazelcast_overload , protocol::HAZELCAST_OVERLOAD,
true);
90 DEFINE_EXCEPTION_CLASS(hazelcast_serialization , protocol::HAZELCAST_SERIALIZATION,
true);
91 DEFINE_EXCEPTION_CLASS(illegal_argument , protocol::ILLEGAL_ARGUMENT,
true);
92 DEFINE_EXCEPTION_CLASS(illegal_monitor_state , protocol::ILLEGAL_MONITOR_STATE,
true);
93 DEFINE_EXCEPTION_CLASS(illegal_state , protocol::ILLEGAL_STATE,
true);
94 DEFINE_EXCEPTION_CLASS(illegal_thread_state , protocol::ILLEGAL_THREAD_STATE,
true);
95 DEFINE_EXCEPTION_CLASS(index_out_of_bounds , protocol::INDEX_OUT_OF_BOUNDS,
true);
96 DEFINE_EXCEPTION_CLASS(invalid_address , protocol::INVALID_ADDRESS,
true);
97 DEFINE_EXCEPTION_CLASS(invalid_configuration , protocol::INVALID_CONFIGURATION,
true);
98 DEFINE_EXCEPTION_CLASS(negative_array_size , protocol::NEGATIVE_ARRAY_SIZE,
true);
99 DEFINE_EXCEPTION_CLASS(no_such_element , protocol::NO_SUCH_ELEMENT,
true);
100 DEFINE_EXCEPTION_CLASS(null_pointer , protocol::NULL_POINTER,
true);
101 DEFINE_EXCEPTION_CLASS(operation_timeout , protocol::OPERATION_TIMEOUT,
true);
102 DEFINE_EXCEPTION_CLASS(query , protocol::QUERY,
true);
103 DEFINE_EXCEPTION_CLASS(query_result_size_exceeded , protocol::QUERY_RESULT_SIZE_EXCEEDED,
true);
104 DEFINE_EXCEPTION_CLASS(split_brain_protection , protocol::SPLIT_BRAIN_PROTECTION,
true);
105 DEFINE_EXCEPTION_CLASS(reached_max_size , protocol::REACHED_MAX_SIZE,
true);
106 DEFINE_EXCEPTION_CLASS(rejected_execution , protocol::REJECTED_EXECUTION,
true);
107 DEFINE_EXCEPTION_CLASS(response_already_sent , protocol::RESPONSE_ALREADY_SENT,
true);
108 DEFINE_EXCEPTION_CLASS(runtime , protocol::RUNTIME,
true);
109 DEFINE_EXCEPTION_CLASS(SecurityException, protocol::SECURITY,
true);
113 DEFINE_EXCEPTION_CLASS(stale_sequence , protocol::STALE_SEQUENCE,
true);
114 DEFINE_EXCEPTION_CLASS(target_disconnected , protocol::TARGET_DISCONNECTED,
true);
115 DEFINE_EXCEPTION_CLASS(topic_overload , protocol::TOPIC_OVERLOAD,
true);
117 DEFINE_EXCEPTION_CLASS(transaction , protocol::TRANSACTION,
true);
118 DEFINE_EXCEPTION_CLASS(transaction_not_active , protocol::TRANSACTION_NOT_ACTIVE,
true);
119 DEFINE_EXCEPTION_CLASS(transaction_timed_out , protocol::TRANSACTION_TIMED_OUT,
true);
120 DEFINE_EXCEPTION_CLASS(unsupported_operation , protocol::UNSUPPORTED_OPERATION,
true);
121 DEFINE_EXCEPTION_CLASS(access_control , protocol::ACCESS_CONTROL,
true);
122 DEFINE_EXCEPTION_CLASS(no_data_member_in_cluster, protocol::NO_DATA_MEMBER,
true);
123 DEFINE_EXCEPTION_CLASS(replicated_map_cant_be_created_on_lite_member, protocol::REPLICATED_MAP_CANT_BE_CREATED,
true);
124 DEFINE_EXCEPTION_CLASS(max_message_size_exceeded, protocol::MAX_MESSAGE_SIZE_EXCEEDED,
true);
125 DEFINE_EXCEPTION_CLASS(wan_replication_queue_full, protocol::WAN_REPLICATION_QUEUE_FULL,
true);
126 DEFINE_EXCEPTION_CLASS(service_not_found, protocol::SERVICE_NOT_FOUND,
true);
128 DEFINE_EXCEPTION_CLASS(stale_task_id, protocol::STALE_TASK_ID,
true);
130 DEFINE_EXCEPTION_CLASS(duplicate_task, protocol::DUPLICATE_TASK,
true);
132 DEFINE_EXCEPTION_CLASS(stale_task, protocol::STALE_TASK,
true);
134 DEFINE_EXCEPTION_CLASS(local_member_reset, protocol::LOCAL_MEMBER_RESET,
true);
136 DEFINE_EXCEPTION_CLASS(indeterminate_operation_state, protocol::INDETERMINATE_OPERATION_STATE,
true);
138 DEFINE_EXCEPTION_CLASS(node_id_out_of_range, protocol::FLAKE_ID_NODE_ID_OUT_OF_RANGE_EXCEPTION,
true);
140 DEFINE_EXCEPTION_CLASS(mutation_disallowed, protocol::MUTATION_DISALLOWED_EXCEPTION,
true);
142 DEFINE_EXCEPTION_CLASS(session_expired, protocol::SESSION_EXPIRED_EXCEPTION,
true);
144 DEFINE_EXCEPTION_CLASS(wait_key_cancelled , protocol::WAIT_KEY_CANCELLED_EXCEPTION,
true);
146 DEFINE_EXCEPTION_CLASS(lock_acquire_limit_reached, protocol::LOCK_ACQUIRE_LIMIT_REACHED_EXCEPTION,
true);
148 DEFINE_EXCEPTION_CLASS(lock_ownership_lost, protocol::LOCK_OWNERSHIP_LOST_EXCEPTION,
true);
150 DEFINE_EXCEPTION_CLASS(cp_group_destroyed, protocol::CP_GROUP_DESTROYED_EXCEPTION,
true);
152 DEFINE_EXCEPTION_CLASS(cannot_replicate, protocol::CANNOT_REPLICATE_EXCEPTION,
true);
154 DEFINE_EXCEPTION_CLASS(leader_demoted, protocol::LEADER_DEMOTED_EXCEPTION,
true);
156 DEFINE_EXCEPTION_CLASS(stale_append_request, protocol::STALE_APPEND_REQUEST_EXCEPTION,
true);
158 DEFINE_EXCEPTION_CLASS(not_leader, protocol::NOT_LEADER_EXCEPTION,
true);
160 DEFINE_EXCEPTION_CLASS(version_mismatch, protocol::VERSION_MISMATCH_EXCEPTION,
true);
164 retryable_hazelcast(
const std::string &error_name, int32_t error_code,
const std::string &source,
165 const std::string &message,
const std::string &details,
166 std::exception_ptr cause,
bool runtime,
169 explicit retryable_hazelcast(
const std::string &source =
"",
const std::string &message =
"",
170 const std::string &details =
"", std::exception_ptr cause =
nullptr);
173 #define DEFINE_RETRYABLE_EXCEPTION_CLASS(ClassName, errorNo) \
174 class HAZELCAST_API ClassName : public retryable_hazelcast {\
176 explicit ClassName(const std::string& source = "", const std::string& message = "", const std::string& details = "", std::exception_ptr cause = nullptr) \
177 : retryable_hazelcast(#ClassName, errorNo, source, message, details, cause, false, true) {} \
181 DEFINE_RETRYABLE_EXCEPTION_CLASS(caller_not_member, protocol::CALLER_NOT_MEMBER);
182 DEFINE_RETRYABLE_EXCEPTION_CLASS(partition_migrating, protocol::PARTITION_MIGRATING);
183 DEFINE_RETRYABLE_EXCEPTION_CLASS(retryable_io, protocol::RETRYABLE_IO);
184 DEFINE_RETRYABLE_EXCEPTION_CLASS(target_not_member, protocol::TARGET_NOT_MEMBER);
185 DEFINE_RETRYABLE_EXCEPTION_CLASS(wrong_target, protocol::WRONG_TARGET);
187 DEFINE_RETRYABLE_EXCEPTION_CLASS(target_not_replica, protocol::TARGET_NOT_REPLICA_EXCEPTION);
191 explicit member_left(
const std::string &source =
"",
const std::string &message =
"",
192 const std::string &details =
"", std::exception_ptr cause =
nullptr);
201 explicit consistency_lost(
const std::string &source =
"",
const std::string &message =
"",
202 const std::string &details =
"", std::exception_ptr cause =
nullptr);
205 DEFINE_EXCEPTION_CLASS(hazelcast_client_not_active, protocol::HAZELCAST_INSTANCE_NOT_ACTIVE,
true);
207 DEFINE_EXCEPTION_CLASS(hazelcast_client_offline, protocol::HAZELCAST_CLIENT_OFFLINE,
true);
215 DEFINE_EXCEPTION_CLASS(unknown_host, protocol::UNKNOWN_HOST,
false);
217 DEFINE_EXCEPTION_CLASS(client_not_allowed_in_cluster, protocol::CLIENT_NOT_ALLOWED_IN_CLUSTER,
true);
225 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)