Couchbase C++ SDK 1.0.4 (rev. 5355b0f)
Loading...
Searching...
No Matches
error_codes.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * Copyright 2020-Present Couchbase, Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#pragma once
19
20#include <system_error>
21
22namespace couchbase
23{
24#ifndef COUCHBASE_CXX_CLIENT_DOXYGEN
25namespace core::impl
26{
27const std::error_category&
28common_category() noexcept;
29
30const std::error_category&
31key_value_category() noexcept;
32
33const std::error_category&
34query_category() noexcept;
35
36const std::error_category&
37analytics_category() noexcept;
38
39const std::error_category&
40search_category() noexcept;
41
42const std::error_category&
43view_category() noexcept;
44
45const std::error_category&
46management_category() noexcept;
47
48const std::error_category&
49field_level_encryption_category() noexcept;
50
51const std::error_category&
52network_category() noexcept;
53
54const std::error_category&
55streaming_json_lexer_category() noexcept;
56
57const std::error_category&
58transaction_category() noexcept;
59
60const std::error_category&
61transaction_op_category() noexcept;
62
63} // namespace core::impl
64#endif
65
66namespace errc
67{
74enum class common {
84
95
106
113 // Query: Error range 5xxx
114 // Analytics: Error range 25xxx
115 // KV: error code ERR_INTERNAL (0x84)
116 // Search: HTTP 500
118
125 // Query: Error range 10xxx
126 // Analytics: Error range 20xxx
127 // View: HTTP status 401
128 // KV: error code ERR_ACCESS (0x24), ERR_AUTH_ERROR (0x20), AUTH_STALE (0x1f)
129 // Search: HTTP status 401, 403
131
140 // Analytics: Errors: 23000, 23003
141 // KV: Error code ERR_TMPFAIL (0x86), ERR_BUSY (0x85) ERR_OUT_OF_MEMORY (0x82),
142 // ERR_NOT_INITIALIZED (0x25)
144
151 // Query: code 3000
152 // Analytics: codes 24000
153 parsing_failure = 8,
154
168 // KV: ERR_EXISTS (0x02) when replace or remove with cas
169 // Query: code 12009
170 cas_mismatch = 9,
171
178 bucket_not_found = 10,
179
187
194 // KV: 0x81 (unknown command), 0x83 (not supported)
196
207
217
225
232 scope_not_found = 16,
233
240 // Query: Codes 12004, 12016 (warning: regex ahead!) Codes 5000 AND message contains index .+ not
241 // found Analytics: Raised When 24047 Search: Http status code 400 AND text contains “index not
242 // found”
243 index_not_found = 17,
244
251 // Query:
252 // Note: the uppercase index for 5000 is not a mistake (also only match on exist not exists
253 // because there is a typo
254 // somewhere in query engine which might either print exist or exists depending on the codepath)
255 // Code 5000 AND message contains Index .+ already exist
256 // Code 4300 AND message contains index .+ already exist
257 //
258 // Analytics: Raised When 24048
259 index_exists = 18,
260
267 encoding_failure = 19,
268
275 decoding_failure = 20,
276
287 /*
288 * Raised when a service decides that the caller must be rate limited due to exceeding a rate
289 * threshold of some sort.
290 *
291 * * KeyValue
292 * 0x30 RateLimitedNetworkIngress -> NetworkIngressRateLimitReached
293 * 0x31 RateLimitedNetworkEgress -> NetworkEgressRateLimitReached
294 * 0x32 RateLimitedMaxConnections -> MaximumConnectionsReached
295 * 0x33 RateLimitedMaxCommands -> RequestRateLimitReached
296 *
297 * * Cluster Manager (body check tbd)
298 * HTTP 429, Body contains "Limit(s) exceeded [num_concurrent_requests]" ->
299 * ConcurrentRequestLimitReached HTTP 429, Body contains "Limit(s) exceeded [ingress]" ->
300 * NetworkIngressRateLimitReached HTTP 429, Body contains "Limit(s) exceeded [egress]" ->
301 * NetworkEgressRateLimitReached Note: when multiple user limits are exceeded the array would
302 * contain all the limits exceeded, as "Limit(s) exceeded [num_concurrent_requests,egress]"
303 *
304 * * Query
305 * Code 1191, Message E_SERVICE_USER_REQUEST_EXCEEDED -> RequestRateLimitReached
306 * Code 1192, Message E_SERVICE_USER_REQUEST_RATE_EXCEEDED -> ConcurrentRequestLimitReached
307 * Code 1193, Message E_SERVICE_USER_REQUEST_SIZE_EXCEEDED -> NetworkIngressRateLimitReached
308 * Code 1194, Message E_SERVICE_USER_RESULT_SIZE_EXCEEDED -> NetworkEgressRateLimitReached
309 *
310 * * Search
311 * HTTP 429, {"status": "fail", "error": "num_concurrent_requests, value >= limit"} ->
312 * ConcurrentRequestLimitReached HTTP 429, {"status": "fail", "error": "num_queries_per_min, value
313 * >= limit"}: -> RequestRateLimitReached HTTP 429, {"status": "fail", "error":
314 * "ingress_mib_per_min >= limit"} -> NetworkIngressRateLimitReached HTTP 429, {"status": "fail",
315 * "error": "egress_mib_per_min >= limit"} -> NetworkEgressRateLimitReached
316 *
317 * * Analytics
318 * Not applicable at the moment.
319 *
320 * * Views
321 * Not applicable.
322 */
323 rate_limited = 21,
324
332 /*
333 * Raised when a service decides that the caller must be limited due to exceeding a quota
334 * threshold of some sort.
335 *
336 * * KeyValue
337 * 0x34 ScopeSizeLimitExceeded
338 *
339 * * Cluster Manager
340 * HTTP 429, Body contains "Maximum number of collections has been reached for scope
341 * "<scope_name>""
342 *
343 * * Query
344 * Code 5000, Body contains "Limit for number of indexes that can be created per scope has been
345 * reached. Limit : value"
346 *
347 * * Search
348 * HTTP 400 (Bad request), {"status": "fail", "error": "rest_create_index: error creating index:
349 * {indexName}, err: manager_api: CreateIndex, Prepare failed, err: num_fts_indexes (active +
350 * pending) >= limit"}
351 * * Analytics
352 * Not applicable at the moment
353 *
354 * * Views
355 * Not applicable
356 */
357 quota_limited = 22,
358};
359
366enum class key_value {
373 // KV Code 0x01
374 document_not_found = 101,
375
385
396 // KV Code 0x09
397 document_locked = 103,
398
405 // KV Code 0x03
406 value_too_large = 104,
407
414 // KV Code 0x02
415 document_exists = 105,
416
423 // KV Code 0xa0
425
433 // KV Code 0xa1
435
444 // KV Code 0xa3
446
453 // KV Code 0xa2
455
463 // KV Code 0xa4
465
472 // KV Code 0xc0
473 path_not_found = 113,
474
482 // KV Code 0xc1
483 path_mismatch = 114,
484
491 // KV Code 0xc2
492 path_invalid = 115,
493
501 // KV Code 0xc3
502 path_too_big = 116,
503
510 // KV Code 0xc4
511 path_too_deep = 117,
512
520 // KV Code 0xca
521 value_too_deep = 118,
522
530 // KV Code 0xc5
531 value_invalid = 119,
532
539 // KV Code 0xc6
540 document_not_json = 120,
541
548 // KV Code 0xc7
549 number_too_big = 121,
550
557 // KV Code 0xc8
558 delta_invalid = 122,
559
566 // KV Code 0xc9
567 path_exists = 123,
568
575 // KV Code: 0xd0
577
584 // KV Code: 0xcf
586
593 // KV Code: 0xd1
595
602 // KV Code: 0xd2
604
613 // KV Code: 0x24
614 xattr_no_access = 130,
615
623 // KV Code: 0x0e
625
632 // KV Code: 0xd6
634
641 // KV Code: 0xa8
643
647 // KV Code: 0xa7
649};
650
657enum class query {
664 // Raised When code range 4xxx other than those explicitly covered
665 planning_failure = 201,
666
674 // Raised When code range 12xxx and 14xxx (other than 12004 and 12016)
675 index_failure = 202,
676
683 // Raised When codes 4040, 4050, 4060, 4070, 4080, 4090
685
692 // Raised when code 12009 AND message does not contain CAS mismatch
693 dml_failure = 204,
694};
695
702enum class analytics {
709 // Error range 24xxx (excluded are specific codes in the errors below)
711
718 // Error code 23007
719 job_queue_full = 302,
720
727 // Error codes 24044, 24045, 24025
728 dataset_not_found = 303,
729
736 // Error code 24034
738
745 // Raised When 24040
746 dataset_exists = 305,
747
754 // Raised When 24039
755 dataverse_exists = 306,
756
763 // Raised When 24006
764 link_not_found = 307,
765
772 // Raised When 24055
773 link_exists = 308,
774};
775
782enum class search {
789 index_not_ready = 401,
790
798};
799
806enum class view {
813 // Http status code 404
814 // Reason or error contains "not_found"
815 view_not_found = 501,
816
823 // Raised on the Management APIs only when
824 // * Getting a design document
825 // * Dropping a design document
826 // * And the server returns 404
828};
829
836enum class management {
838 collection_exists = 601,
839
841 scope_exists = 602,
842
844 user_not_found = 603,
845
847 group_not_found = 604,
848
850 bucket_exists = 605,
851
853 user_exists = 606,
854
857
861
865
869
873
877
881
885};
886
901
910 encryption_failure = 701,
911
920 decryption_failure = 702,
921
929
937 invalid_crypto_key = 704,
938
947
956
963 invalid_ciphertext = 707,
964};
965
972enum class network {
979 resolve_failure = 1001,
980
987 no_endpoints_left = 1002,
988
995 handshake_failure = 1003,
996
1003 protocol_error = 1004,
1004
1012
1019 cluster_closed = 1006,
1020
1025 end_of_stream = 1007,
1026
1031 need_more_data = 1008,
1032
1038
1043 operation_queue_full = 1010,
1044
1050
1055 request_cancelled = 1012,
1056
1061 bucket_closed = 1013,
1062};
1063
1071 garbage_trailing = 1101,
1072 special_expected = 1102,
1073 special_incomplete = 1103,
1074 stray_token = 1104,
1075 missing_token = 1105,
1076 cannot_insert = 1106,
1077 escape_outside_string = 1107,
1078 key_outside_object = 1108,
1080 found_null_byte = 1110,
1081 levels_exceeded = 1111,
1082 bracket_mismatch = 1112,
1083 object_key_expected = 1113,
1084 weird_whitespace = 1114,
1086 escape_invalid = 1116,
1087 trailing_comma = 1117,
1088 invalid_number = 1118,
1089 value_expected = 1119,
1090 percent_bad_hex = 1120,
1091 json_pointer_bad_path = 1121,
1094 not_enough_memory = 1124,
1095 invalid_codepoint = 1125,
1096 generic = 1126,
1097 root_is_not_an_object = 1127,
1099};
1100
1107enum class transaction {
1108 failed = 1200,
1109 expired = 1201,
1110 failed_post_commit = 1202,
1111 ambiguous = 1203,
1112};
1113
1151
1152#ifndef COUCHBASE_CXX_CLIENT_DOXYGEN
1153inline std::error_code
1154make_error_code(common e) noexcept
1155{
1156 return { static_cast<int>(e), core::impl::common_category() };
1157}
1158
1159inline std::error_code
1160make_error_code(key_value e)
1161{
1162 return { static_cast<int>(e), core::impl::key_value_category() };
1163}
1164
1165inline std::error_code
1166make_error_code(query e)
1167{
1168 return { static_cast<int>(e), core::impl::query_category() };
1169}
1170
1171inline std::error_code
1172make_error_code(search e)
1173{
1174 return { static_cast<int>(e), core::impl::search_category() };
1175}
1176
1177inline std::error_code
1178make_error_code(view e)
1179{
1180 return { static_cast<int>(e), core::impl::view_category() };
1181}
1182
1183inline std::error_code
1184make_error_code(analytics e)
1185{
1186 return { static_cast<int>(e), core::impl::analytics_category() };
1187}
1188
1189inline std::error_code
1190make_error_code(management e)
1191{
1192 return { static_cast<int>(e), core::impl::management_category() };
1193}
1194
1195inline std::error_code
1196make_error_code(network e)
1197{
1198 return { static_cast<int>(e), core::impl::network_category() };
1199}
1200
1201inline std::error_code
1202make_error_code(field_level_encryption e)
1203{
1204 return { static_cast<int>(e), core::impl::field_level_encryption_category() };
1205}
1206
1207inline std::error_code
1208make_error_code(streaming_json_lexer e)
1209{
1210 return { static_cast<int>(e), core::impl::streaming_json_lexer_category() };
1211}
1212
1213inline std::error_code
1214make_error_code(transaction e)
1215{
1216 return { static_cast<int>(e), core::impl::transaction_category() };
1217}
1218
1219inline std::error_code
1220make_error_code(transaction_op e)
1221{
1222 return { static_cast<int>(e), core::impl::transaction_op_category() };
1223}
1224
1225#endif
1226} // namespace errc
1227} // namespace couchbase
1228
1229#ifndef COUCHBASE_CXX_CLIENT_DOXYGEN
1230template<>
1231struct std::is_error_code_enum<couchbase::errc::common> : std::true_type {
1232};
1233
1234template<>
1235struct std::is_error_code_enum<couchbase::errc::key_value> : std::true_type {
1236};
1237
1238template<>
1239struct std::is_error_code_enum<couchbase::errc::query> : std::true_type {
1240};
1241
1242template<>
1243struct std::is_error_code_enum<couchbase::errc::analytics> : std::true_type {
1244};
1245
1246template<>
1247struct std::is_error_code_enum<couchbase::errc::search> : std::true_type {
1248};
1249
1250template<>
1251struct std::is_error_code_enum<couchbase::errc::view> : std::true_type {
1252};
1253
1254template<>
1255struct std::is_error_code_enum<couchbase::errc::management> : std::true_type {
1256};
1257
1258template<>
1259struct std::is_error_code_enum<couchbase::errc::field_level_encryption> : std::true_type {
1260};
1261
1262template<>
1263struct std::is_error_code_enum<couchbase::errc::network> : std::true_type {
1264};
1265
1266template<>
1267struct std::is_error_code_enum<couchbase::errc::streaming_json_lexer> : std::true_type {
1268};
1269
1270template<>
1271struct std::is_error_code_enum<couchbase::errc::transaction> : std::true_type {
1272};
1273
1274template<>
1275struct std::is_error_code_enum<couchbase::errc::transaction_op> : std::true_type {
1276};
1277
1278#endif
transaction_op
Errors related to a failed transaction operation.
Definition error_codes.hxx:1120
key_value
Errors for related to Key/Value service (kv_engine)
Definition error_codes.hxx:366
@ path_exists
A sub-document operation which relies on a path not existing encountered a path which exists.
@ value_too_large
The value that was sent was too large to store (typically > 20MB)
@ xattr_unknown_virtual_attribute
A sub-document operation attempts to access an unknown virtual attribute.
@ document_not_locked
The document is already locked - generally returned when an unlocking operation is being performed.
@ value_too_deep
The value provided, if inserted into the document, would cause the document to become too deep for th...
@ xattr_unknown_macro
A macro was used which the server did not understand.
@ durable_write_re_commit_in_progress
The server is currently working to synchronize all replicas for previously performed durable operatio...
@ xattr_invalid_key_combo
A sub-document operation attempts to access multiple XATTRs in one operation.
@ path_too_deep
The document contains too many levels to parse.
@ document_not_found
Indicates an operation failed because the key does not exist.
@ path_mismatch
The path provided for a sub-document operation did not match the actual structure of the document.
@ cannot_revive_living_document
Only deleted document could be revived.
@ xattr_no_access
The user does not have permission to access the attribute.
@ durable_write_in_progress
A durable write is attempted against a key which already has a pending durable write.
@ document_locked
Returned when the server reports a temporary failure that is very likely to be lock-related (like an ...
@ durability_ambiguous
A sync-write has not completed in the specified time and has an ambiguous result – it may have succee...
@ path_not_found
The path provided for a sub-document operation was not found.
@ document_not_json
A sub-document operation is performed on a non-JSON document.
@ xattr_cannot_modify_virtual_attribute
A sub-document operation attempts to modify a virtual attribute.
@ number_too_big
The existing number is outside the valid range for arithmetic operations.
@ document_exists
An operation which relies on the document not existing fails because the document existed.
@ path_invalid
The path provided for a sub-document operation was not syntactically correct.
@ durability_impossible
The specified durability requirements are not currently possible (for example, there are an insuffici...
@ mutation_token_outdated
The provided mutation token is outdated compared to the current state of the server.
@ document_irretrievable
In collection::get_any_replica, the collection::get_all_replicas returns an empty stream because all ...
@ value_invalid
The value provided for a sub-document operation would invalidate the JSON structure of the document i...
@ delta_invalid
The delta value specified for an operation is too large.
@ durability_level_not_available
The specified durability level is invalid.
@ path_too_big
The path provided for a sub-document operation is too long, or contains too many independent componen...
field_level_encryption
Field-Level Encryption Error Definitions.
Definition error_codes.hxx:893
@ invalid_crypto_key
Raised by an encrypter or decrypter when the key does not meet expectations (for example,...
@ encrypter_not_found
Raised when a message cannot be encrypted because there is no encrypter registered under the requeste...
@ generic_cryptography_failure
Generic cryptography failure.
@ encryption_failure
Raised by CryptoManager encrypt when encryption fails for any reason.
@ crypto_key_not_found
Raised when a crypto operation fails because a required key is missing.
@ decryption_failure
Raised by CryptoManager.decrypt() when decryption fails for any reason.
@ decrypter_not_found
Raised when a message cannot be decrypted because there is no decrypter registered for the algorithm.
@ invalid_ciphertext
Raised when decryption fails due to malformed input, integrity check failure, etc.
search
Errors related to Search service (CBFT)
Definition error_codes.hxx:782
@ consistency_mismatch
Consistency constraints cannot be accepted by the server.
@ index_not_ready
The index referenced in the query is not ready yet.
view
Errors related to Views service (CAPI)
Definition error_codes.hxx:806
@ view_not_found
View does not exist on the server.
@ design_document_not_found
Design document does not exist on the server.
network
Errors related to networking IO.
Definition error_codes.hxx:972
@ resolve_failure
Unable to resolve node address.
@ handshake_failure
Failed to complete protocol handshake.
@ protocol_error
Unexpected protocol state or input.
@ no_endpoints_left
No hosts left to connect.
@ configuration_not_available
Configuration is not available for some reason.
@ cluster_closed
The cluster object has been explicitly closed, no requests allowed.
query
Errors related to Query service (N1QL)
Definition error_codes.hxx:657
@ planning_failure
Indicates an operation failed because there has been an issue with the query planner.
@ index_failure
Indicates an operation failed because there has been an issue with the query planner or similar.
@ dml_failure
This exception is raised when the server fails to execute a DML query.
@ prepared_statement_failure
Indicates an operation failed because there has been an issue with query prepared statements.
transaction
Errors related to a failed transaction.
Definition error_codes.hxx:1107
management
Errors related to management service (ns_server)
Definition error_codes.hxx:836
@ group_not_found
Raised from the user management API.
@ eventing_function_compilation_failure
Occurs when the compilation of the function code failed name is "ERR_HANDLER_COMPILATION".
@ eventing_function_identical_keyspace
Occurs when source and metadata keyspaces are the same.
@ bucket_not_flushable
Raised from the bucket management API.
@ eventing_function_paused
Occurs when a function is paused but the action does not expect it to name is "ERR_APP_PAUSED".
@ eventing_function_not_bootstrapped
Occurs when a function is deployed but not “fully” bootstrapped name is "ERR_APP_NOT_BOOTSTRAPPED".
@ eventing_function_deployed
Occurs when a function is deployed but the action does not expect it to name is "ERR_APP_NOT_UNDEPLOY...
@ eventing_function_not_deployed
Occurs if the function is not deployed, but the action expects it to name is "ERR_APP_NOT_DEPLOYED".
@ user_not_found
Raised from the user management API.
@ collection_exists
Raised from the collection management API.
@ eventing_function_not_found
Occurs if the function is not found name is "ERR_APP_NOT_FOUND_TS".
@ scope_exists
Raised from the collection management API.
@ user_exists
Raised from the user management API.
@ bucket_exists
Raised from the bucket management API.
analytics
Errors related to Analytics service (CBAS)
Definition error_codes.hxx:702
@ link_not_found
The link referenced in the query is not found on the server.
@ job_queue_full
Indicates the analytics server job queue is full.
@ dataset_not_found
The dataset referenced in the query is not found on the server.
@ link_exists
The link referenced in the query is found on the server, when it should not be.
@ dataverse_not_found
The dataverse referenced in the query is not found on the server.
@ dataverse_exists
The dataverse referenced in the query is found on the server, when it should not be.
@ dataset_exists
The dataset referenced in the query is found on the server, when it should not be.
@ compilation_failure
The query failed to compile.
streaming_json_lexer
Errors related to streaming JSON parser.
Definition error_codes.hxx:1070
common
Common errors for all services and modules.
Definition error_codes.hxx:74
@ bucket_not_found
A request is made but the current bucket is not found.
@ cas_mismatch
Indicates an optimistic locking failure.
@ service_not_available
It can be determined from the config unambiguously that a given service is not available.
@ encoding_failure
Returned when encoding of a user object failed while trying to write it to the cluster.
@ internal_server_failure
Indicates an operation failed because there has been an internal error in the server.
@ temporary_failure
Returned when the server reports a temporary failure.
@ decoding_failure
Returned when decoding of the data into the user object failed.
@ unambiguous_timeout
A timeout occurs and we are confident that the operation could not have succeeded.
@ rate_limited
This error is raised if the operation failed due to hitting a rate-limit on the server side.
@ ambiguous_timeout
A timeout occurs and we aren't sure if the underlying operation has completed.
@ collection_not_found
A request is made but the current collection (including scope) is not found.
@ scope_not_found
A management API attempts to target a scope which does not exist.
@ index_not_found
The index that was referenced by the operation does not exist on the server.
@ feature_not_available
A feature which is not available was used.
@ index_exists
The index that was referenced by the operation exist on the server when it expected not to.
@ unsupported_operation
The server indicates that the operation is not supported.
@ authentication_failure
Indicates authentication problems.
@ parsing_failure
Indicates an operation failed because parsing of the input returned with an error.
@ invalid_argument
It is unambiguously determined that the error was caused because of invalid arguments from the user.
@ quota_limited
This error is raised if the operation failed due to hitting a quota-limit on the server side.
@ request_canceled
A request is cancelled and cannot be resolved in a non-ambiguous way.
Represents a single item from the result of collection::scan()
Definition allow_querying_search_index_options.hxx:28