3 #include <zk/config.hpp>
17 #define ZKPP_ERROR_CODE_LIST(item) \
19 item(system_error, -1, ZSYSTEMERROR) \
20 item(runtime_inconsistency, -2, ZRUNTIMEINCONSISTENCY) \
21 item(data_inconsistency, -3, ZDATAINCONSISTENCY) \
22 item(connection_loss, -4, ZCONNECTIONLOSS) \
23 item(marshalling_error, -5, ZMARSHALLINGERROR) \
24 item(unimplemented, -6, ZUNIMPLEMENTED) \
25 item(operation_timeout, -7, ZOPERATIONTIMEOUT) \
26 item(invalid_arguments, -8, ZBADARGUMENTS) \
27 item(invalid_handle_state, -9, ZINVALIDSTATE) \
28 item(unknown_session, -12, ZUNKNOWNSESSION) \
29 item(new_configuration_no_quorum, -13, ZNEWCONFIGNOQUORUM) \
30 item(reconfiguration_in_progress, -14, ZRECONFIGINPROGRESS) \
31 item(api_error, -100, ZAPIERROR) \
32 item(no_node, -101, ZNONODE) \
33 item(not_authenticated, -102, ZNOAUTH) \
34 item(bad_version, -103, ZBADVERSION) \
35 item(no_children_for_ephemerals, -108, ZNOCHILDRENFOREPHEMERALS) \
36 item(node_exists, -110, ZNODEEXISTS) \
37 item(not_empty, -111, ZNOTEMPTY) \
38 item(session_expired, -112, ZSESSIONEXPIRED) \
39 item(invalid_callback, -113, ZINVALIDCALLBACK) \
40 item(invalid_acl, -114, ZINVALIDACL) \
41 item(authentication_failed, -115, ZAUTHFAILED) \
42 item(closing, -116, ZCLOSING) \
43 item(no_response, -117, ZNOTHING) \
44 item(session_moved, -118, ZSESSIONMOVED) \
45 item(server_read_only, -119, ZNOTREADONLY) \
46 item(ephemeral_on_local_session, -120, ZEPHEMERALONLOCALSESSION) \
47 item(no_watcher, -121, ZNOWATCHER) \
48 item(reconfiguration_disabled, -123, ZRECONFIGDISABLED) \
49 item(transaction_failed, -199, ZTRANSACTIONFAILED) \
51 enum class error_code : int
53 #define ZKPP_ERROR_CODE_ENUM_DEF_IMPL(cxx_name, number, c_name) \
56 ZKPP_ERROR_CODE_LIST(ZKPP_ERROR_CODE_ENUM_DEF_IMPL)
59 std::ostream& operator<<(std::ostream&,
const error_code&);
61 std::string to_string(
const error_code&);
63 #define ZKPP_ERROR_CODE_SIZE_IMPL(cxx_name, number, c_name) +1
65 const std::array<error_code, ZKPP_ERROR_CODE_LIST(ZKPP_ERROR_CODE_SIZE_IMPL)>& all_error_codes();
67 constexpr
bool is_system_error(error_code code)
69 return static_cast<int>(code) <= static_cast<int>(error_code::system_error)
70 &&
static_cast<int>(code) > static_cast<int>(error_code::api_error);
73 constexpr
bool is_api_error(error_code code)
75 return static_cast<int>(code) <= static_cast<int>(error_code::api_error);
79 void throw_error(error_code code);
81 std::exception_ptr get_exception_ptr_of(error_code code);
84 public std::runtime_error
87 explicit error(error_code code, std::string description);
89 virtual ~
error() noexcept;
91 error_code code()
const {
return _code; }
101 explicit system_error(error_code code, std::string description);
209 explicit api_error(error_code code, std::string description);
389 error_code _underlying_cause;
390 std::size_t _op_index;
std::size_t failed_op_index() const
The transaction index which caused the error (0 indexed).
error_code underlying_cause() const
The underlying cause that caused this transaction to be aborted.
Thrown from client::commit when a transaction cannot be committed to the system.