Couchbase C Client  3.2.2
Asynchronous C Client for Couchbase
error.h
Go to the documentation of this file.
1 /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /*
3  * Copyright 2012-2020 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 
23 #ifndef LIBCOUCHBASE_ERROR_H
24 #define LIBCOUCHBASE_ERROR_H 1
25 
26 #ifndef LIBCOUCHBASE_COUCHBASE_H
27 #error "Include libcouchbase/couchbase.h instead"
28 #endif
29 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 typedef enum {
43  LCB_ERROR_TYPE_SUCCESS = 0,
44  LCB_ERROR_TYPE_BASE = 1,
45  LCB_ERROR_TYPE_SHARED = 2,
46  LCB_ERROR_TYPE_KEYVALUE = 3,
47  LCB_ERROR_TYPE_QUERY = 4,
48  LCB_ERROR_TYPE_ANALYTICS = 5,
49  LCB_ERROR_TYPE_SEARCH = 6,
50  LCB_ERROR_TYPE_VIEW = 7,
51  LCB_ERROR_TYPE_MANAGEMENT = 8,
52  LCB_ERROR_TYPE_SDK = 10
53 } lcb_ERROR_TYPE;
54 
55 typedef enum {
56  LCB_ERROR_FLAG_NETWORK = 1u << 0u,
57  LCB_ERROR_FLAG_SUBDOC = 1u << 1u,
58  LCB_ERROR_FLAG_TRANSIENT = 1u << 2u,
59  LCB_ERROR_FLAG_FATAL = 1u << 3u,
60  LCB_ERROR_FLAG_INPUT = 1u << 4u,
61 } lcb_ERROR_FLAGS;
62 
63 /* clang-format off */
64 #define LCB_XERROR(X) \
65 /* Common Error Definitions */ \
66 X(LCB_SUCCESS, 0, LCB_ERROR_TYPE_SUCCESS, 0, "Success (Not an error)") \
67 X(LCB_ERR_GENERIC, 100, LCB_ERROR_TYPE_BASE, 0, "Generic error code") \
68 \
69 /* Shared Error Definitions */ \
70 X(LCB_ERR_TIMEOUT, 201, LCB_ERROR_TYPE_SHARED, LCB_ERROR_FLAG_NETWORK | LCB_ERROR_FLAG_TRANSIENT, "The request was not completed by the user-defined timeout") \
71 X(LCB_ERR_REQUEST_CANCELED, 202, LCB_ERROR_TYPE_SHARED, 0, "A request is cancelled and cannot be resolved in a non-ambiguous way. Most likely the request is in-flight on the socket and the socket gets closed.") \
72 X(LCB_ERR_INVALID_ARGUMENT, 203, LCB_ERROR_TYPE_SHARED, LCB_ERROR_FLAG_INPUT, "It is unambiguously determined that the error was caused because of invalid arguments from the user") \
73 X(LCB_ERR_SERVICE_NOT_AVAILABLE, 204, LCB_ERROR_TYPE_SHARED, 0, "It was determined from the config unambiguously that the service is not available") \
74 X(LCB_ERR_INTERNAL_SERVER_FAILURE, 205, LCB_ERROR_TYPE_SHARED, 0, "Internal server error") \
75 X(LCB_ERR_AUTHENTICATION_FAILURE, 206, LCB_ERROR_TYPE_SHARED, LCB_ERROR_FLAG_INPUT, "Authentication error") \
76 X(LCB_ERR_TEMPORARY_FAILURE, 207, LCB_ERROR_TYPE_SHARED, LCB_ERROR_FLAG_TRANSIENT, "Temporary failure") \
77 X(LCB_ERR_PARSING_FAILURE, 208, LCB_ERROR_TYPE_SHARED, 0, "Parsing failed") \
78 X(LCB_ERR_CAS_MISMATCH, 209, LCB_ERROR_TYPE_SHARED, LCB_ERROR_FLAG_INPUT, "CAS mismatch") \
79 X(LCB_ERR_BUCKET_NOT_FOUND, 210, LCB_ERROR_TYPE_SHARED, LCB_ERROR_FLAG_INPUT, "A request is made but the current bucket is not found") \
80 X(LCB_ERR_COLLECTION_NOT_FOUND, 211, LCB_ERROR_TYPE_SHARED, 0, "A request is made but the current collection (including scope) is not found") \
81 X(LCB_ERR_ENCODING_FAILURE, 212, LCB_ERROR_TYPE_SHARED, 0, "Encoding of user object failed while trying to write it to the cluster") \
82 X(LCB_ERR_DECODING_FAILURE, 213, LCB_ERROR_TYPE_SHARED, 0, "Decoding of the data into the user object failed") \
83 X(LCB_ERR_UNSUPPORTED_OPERATION, 214, LCB_ERROR_TYPE_SHARED, 0, "Unsupported operation") \
84 X(LCB_ERR_AMBIGUOUS_TIMEOUT, 215, LCB_ERROR_TYPE_SHARED, 0, "Ambiguous timeout") \
85 X(LCB_ERR_UNAMBIGUOUS_TIMEOUT, 216, LCB_ERROR_TYPE_SHARED, 0, "Unambiguous timeout") \
86 X(LCB_ERR_SCOPE_NOT_FOUND, 217, LCB_ERROR_TYPE_SHARED, 0, "Scope is not found") \
87 X(LCB_ERR_INDEX_NOT_FOUND, 218, LCB_ERROR_TYPE_SHARED, 0, "Index is not found") \
88 X(LCB_ERR_INDEX_EXISTS, 219, LCB_ERROR_TYPE_SHARED, 0, "Index is exist already") \
89 \
90 /* KeyValue Error Definitions */ \
91 X(LCB_ERR_DOCUMENT_NOT_FOUND, 301, LCB_ERROR_TYPE_KEYVALUE, 0, "Document is not found") \
92 X(LCB_ERR_DOCUMENT_UNRETRIEVABLE, 302, LCB_ERROR_TYPE_KEYVALUE, 0, "Document is unretrievable") \
93 X(LCB_ERR_DOCUMENT_LOCKED, 303, LCB_ERROR_TYPE_KEYVALUE, 0, "Document locked") \
94 X(LCB_ERR_VALUE_TOO_LARGE, 304, LCB_ERROR_TYPE_KEYVALUE, LCB_ERROR_FLAG_INPUT, "Value too large") \
95 X(LCB_ERR_DOCUMENT_EXISTS, 305, LCB_ERROR_TYPE_KEYVALUE, 0, "Document already exists") \
96 X(LCB_ERR_VALUE_NOT_JSON, 306, LCB_ERROR_TYPE_KEYVALUE, 0, "Value is not a JSON") \
97 X(LCB_ERR_DURABILITY_LEVEL_NOT_AVAILABLE, 307, LCB_ERROR_TYPE_KEYVALUE, LCB_ERROR_FLAG_INPUT, "Durability level is not available") \
98 X(LCB_ERR_DURABILITY_IMPOSSIBLE, 308, LCB_ERROR_TYPE_KEYVALUE, LCB_ERROR_FLAG_INPUT, "Durability impossible") \
99 X(LCB_ERR_DURABILITY_AMBIGUOUS, 309, LCB_ERROR_TYPE_KEYVALUE, LCB_ERROR_FLAG_INPUT, "Durability ambiguous") \
100 X(LCB_ERR_DURABLE_WRITE_IN_PROGRESS, 310, LCB_ERROR_TYPE_KEYVALUE, 0, "Durable write in progress") \
101 X(LCB_ERR_DURABLE_WRITE_RE_COMMIT_IN_PROGRESS, 311, LCB_ERROR_TYPE_KEYVALUE, 0, "Durable write re-commit in progress") \
102 X(LCB_ERR_MUTATION_LOST, 312, LCB_ERROR_TYPE_KEYVALUE, 0, "Mutation lost") \
103 X(LCB_ERR_SUBDOC_PATH_NOT_FOUND, 313, LCB_ERROR_TYPE_KEYVALUE, LCB_ERROR_FLAG_SUBDOC, "Subdoc: path not found") \
104 X(LCB_ERR_SUBDOC_PATH_MISMATCH, 314, LCB_ERROR_TYPE_KEYVALUE, LCB_ERROR_FLAG_SUBDOC, "Subdoc: path mismatch") \
105 X(LCB_ERR_SUBDOC_PATH_INVALID, 315, LCB_ERROR_TYPE_KEYVALUE, LCB_ERROR_FLAG_SUBDOC | LCB_ERROR_FLAG_INPUT, "Subdoc: path invalid") \
106 X(LCB_ERR_SUBDOC_PATH_TOO_BIG, 316, LCB_ERROR_TYPE_KEYVALUE, LCB_ERROR_FLAG_SUBDOC | LCB_ERROR_FLAG_INPUT, "Subdoc: path too big") \
107 X(LCB_ERR_SUBDOC_PATH_TOO_DEEP, 317, LCB_ERROR_TYPE_KEYVALUE, LCB_ERROR_FLAG_SUBDOC | LCB_ERROR_FLAG_INPUT, "Subdoc: document too deep") \
108 X(LCB_ERR_SUBDOC_VALUE_TOO_DEEP, 318, LCB_ERROR_TYPE_KEYVALUE, LCB_ERROR_FLAG_SUBDOC | LCB_ERROR_FLAG_INPUT, "Subdoc: value too deep") \
109 X(LCB_ERR_SUBDOC_VALUE_INVALID, 319, LCB_ERROR_TYPE_KEYVALUE, LCB_ERROR_FLAG_SUBDOC | LCB_ERROR_FLAG_INPUT, "Subdoc: cannot insert value") \
110 X(LCB_ERR_SUBDOC_DOCUMENT_NOT_JSON, 320, LCB_ERROR_TYPE_KEYVALUE, LCB_ERROR_FLAG_SUBDOC, "Subdoc: document is not a JSON") \
111 X(LCB_ERR_SUBDOC_NUMBER_TOO_BIG, 321, LCB_ERROR_TYPE_KEYVALUE, LCB_ERROR_FLAG_SUBDOC | LCB_ERROR_FLAG_INPUT, "Subdoc: number is too big") \
112 X(LCB_ERR_SUBDOC_DELTA_INVALID, 322, LCB_ERROR_TYPE_KEYVALUE, LCB_ERROR_FLAG_SUBDOC | LCB_ERROR_FLAG_INPUT, "Subdoc: invalid delta range") \
113 X(LCB_ERR_SUBDOC_PATH_EXISTS, 323, LCB_ERROR_TYPE_KEYVALUE, LCB_ERROR_FLAG_SUBDOC, "Subdoc: path already exists") \
114 X(LCB_ERR_SUBDOC_XATTR_UNKNOWN_MACRO, 324, LCB_ERROR_TYPE_KEYVALUE, LCB_ERROR_FLAG_SUBDOC | LCB_ERROR_FLAG_INPUT, "Subdoc: XATTR unknown macro") \
115 X(LCB_ERR_SUBDOC_XATTR_INVALID_FLAG_COMBO, 325, LCB_ERROR_TYPE_KEYVALUE, LCB_ERROR_FLAG_SUBDOC | LCB_ERROR_FLAG_INPUT, "Subdoc: XATTR invalid flag combination") \
116 X(LCB_ERR_SUBDOC_XATTR_INVALID_KEY_COMBO, 326, LCB_ERROR_TYPE_KEYVALUE, LCB_ERROR_FLAG_SUBDOC | LCB_ERROR_FLAG_INPUT, "Subdoc: XATTR invalid key combination") \
117 X(LCB_ERR_SUBDOC_XATTR_UNKNOWN_VIRTUAL_ATTRIBUTE, 327, LCB_ERROR_TYPE_KEYVALUE, LCB_ERROR_FLAG_SUBDOC | LCB_ERROR_FLAG_INPUT, "Subdoc: XATTR unknown virtual attribute") \
118 X(LCB_ERR_SUBDOC_XATTR_CANNOT_MODIFY_VIRTUAL_ATTRIBUTE, 328, LCB_ERROR_TYPE_KEYVALUE, LCB_ERROR_FLAG_SUBDOC | LCB_ERROR_FLAG_INPUT, "Subdoc: XATTR cannot modify virtual attribute") \
119 X(LCB_ERR_SUBDOC_XATTR_INVALID_ORDER, 329, LCB_ERROR_TYPE_KEYVALUE, LCB_ERROR_FLAG_SUBDOC | LCB_ERROR_FLAG_INPUT, "Subdoc: XATTR invalid order") \
120 \
121 /* Query Error Definitions */ \
122 X(LCB_ERR_PLANNING_FAILURE, 401, LCB_ERROR_TYPE_QUERY, 0, "Planning failed") \
123 X(LCB_ERR_INDEX_FAILURE, 402, LCB_ERROR_TYPE_QUERY, 0, "Query index failure") \
124 X(LCB_ERR_PREPARED_STATEMENT_FAILURE, 403, LCB_ERROR_TYPE_QUERY, 0, "Prepared statement failure") \
125 X(LCB_ERR_KEYSPACE_NOT_FOUND, 404, LCB_ERROR_TYPE_QUERY, 0, "Keyspace is not found (collection or bucket does not exist)") \
126 X(LCB_ERR_DML_FAILURE, 405, LCB_ERROR_TYPE_QUERY, 0, "Data service returned an error during execution of DML statement") \
127 \
128 /* Analytics Error Definitions */ \
129 X(LCB_ERR_COMPILATION_FAILED, 501, LCB_ERROR_TYPE_ANALYTICS, 0, "Compilation failed") \
130 X(LCB_ERR_JOB_QUEUE_FULL, 502, LCB_ERROR_TYPE_ANALYTICS, 0, "Job queue is full") \
131 X(LCB_ERR_DATASET_NOT_FOUND, 503, LCB_ERROR_TYPE_ANALYTICS, 0, "Dataset is not found") \
132 X(LCB_ERR_DATAVERSE_NOT_FOUND, 504, LCB_ERROR_TYPE_ANALYTICS, 0, "Dataverse is not found") \
133 X(LCB_ERR_DATASET_EXISTS, 505, LCB_ERROR_TYPE_ANALYTICS, 0, "Dataset already exists") \
134 X(LCB_ERR_DATAVERSE_EXISTS, 506, LCB_ERROR_TYPE_ANALYTICS, 0, "Dataverse already exists") \
135 X(LCB_ERR_ANALYTICS_LINK_NOT_FOUND, 507, LCB_ERROR_TYPE_ANALYTICS, 0, "Analytics link is not found") \
136 \
137 /* Search Error Definitions (6xx) */ \
138 \
139 /* View Error Definitions */ \
140 X(LCB_ERR_VIEW_NOT_FOUND, 701, LCB_ERROR_TYPE_VIEW, 0, "View is not found") \
141 X(LCB_ERR_DESIGN_DOCUMENT_NOT_FOUND, 702, LCB_ERROR_TYPE_VIEW, 0, "Design document is not found") \
142 \
143 /* Management API Error Definitions */ \
144 X(LCB_ERR_COLLECTION_ALREADY_EXISTS, 801, LCB_ERROR_TYPE_MANAGEMENT, 0, "Collection already exists") \
145 X(LCB_ERR_SCOPE_EXISTS, 802, LCB_ERROR_TYPE_MANAGEMENT, 0, "Scope already exists") \
146 X(LCB_ERR_USER_NOT_FOUND, 803, LCB_ERROR_TYPE_MANAGEMENT, 0, "User is not found") \
147 X(LCB_ERR_GROUP_NOT_FOUND, 804, LCB_ERROR_TYPE_MANAGEMENT, 0, "Group is not found") \
148 X(LCB_ERR_BUCKET_ALREADY_EXISTS, 805, LCB_ERROR_TYPE_MANAGEMENT, 0, "Bucket already exists") \
149 \
150 /* SDK-specific Error Definitions */ \
151 X(LCB_ERR_SSL_INVALID_CIPHERSUITES, 1000, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_FATAL, "OpenSSL encountered an error in the provided ciphersuites (TLS >= 1.3)") \
152 X(LCB_ERR_SSL_NO_CIPHERS, 1001, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_FATAL, "OpenSSL does not support any of the ciphers provided (TLS < 1.3)") \
153 X(LCB_ERR_SSL_ERROR, 1002, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_FATAL, "A generic error related to the SSL subsystem was encountered. Enable logging to see more details") \
154 X(LCB_ERR_SSL_CANTVERIFY, 1003, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_FATAL, "Client could not verify server's certificate") \
155 X(LCB_ERR_FD_LIMIT_REACHED, 1004, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_NETWORK | LCB_ERROR_FLAG_FATAL, "The system or process has reached its maximum number of file descriptors") \
156 X(LCB_ERR_NODE_UNREACHABLE, 1005, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_NETWORK | LCB_ERROR_FLAG_TRANSIENT, "The remote host is not reachable") \
157 X(LCB_ERR_CONTROL_UNKNOWN_CODE, 1006, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_INPUT, "Control code passed was unrecognized") \
158 X(LCB_ERR_CONTROL_UNSUPPORTED_MODE, 1007, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_INPUT, "Invalid modifier for cntl operation (e.g. tried to read a write-only value") \
159 X(LCB_ERR_CONTROL_INVALID_ARGUMENT, 1008, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_INPUT, "Argument passed to cntl was badly formatted") \
160 X(LCB_ERR_DUPLICATE_COMMANDS, 1009, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_INPUT, "The same key was specified more than once in the command list") \
161 X(LCB_ERR_NO_MATCHING_SERVER, 1010, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_TRANSIENT, "The node the request was mapped to does not exist in the current cluster map. This may be the result of a failover") \
162 X(LCB_ERR_PLUGIN_VERSION_MISMATCH, 1011, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_INPUT | LCB_ERROR_FLAG_FATAL, "This version of libcouchbase cannot load the specified plugin") \
163 X(LCB_ERR_INVALID_HOST_FORMAT, 1012, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_INPUT, "Hostname specified for URI is in an invalid format") \
164 X(LCB_ERR_INVALID_CHAR, 1013, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_INPUT, "Illegal character") \
165 X(LCB_ERR_BAD_ENVIRONMENT, 1014, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_INPUT | LCB_ERROR_FLAG_FATAL, "The value for an environment variable recognized by libcouchbase was specified in an incorrect format. Check your environment for entries starting with 'LCB_' or 'LIBCOUCHBASE_'") \
166 X(LCB_ERR_NO_MEMORY, 1015, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_TRANSIENT, "Memory allocation for libcouchbase failed. Severe problems ahead") \
167 X(LCB_ERR_NO_CONFIGURATION, 1016, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_TRANSIENT, "Client not bootstrapped. Ensure bootstrap/connect was attempted and was successful") \
168 X(LCB_ERR_DLOPEN_FAILED, 1017, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_INPUT | LCB_ERROR_FLAG_FATAL, "Could not locate plugin library") \
169 X(LCB_ERR_DLSYM_FAILED, 1018, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_INPUT | LCB_ERROR_FLAG_FATAL, "Required plugin initializer not found") \
170 X(LCB_ERR_CONFIG_CACHE_INVALID, 1019, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_INPUT, "The contents of the configuration cache file were invalid. Configuration will be fetched from the network") \
171 X(LCB_ERR_COLLECTION_MANIFEST_IS_AHEAD, 1020, LCB_ERROR_TYPE_SDK, 0, "Collections manifest of SDK is ahead of Server's") \
172 X(LCB_ERR_COLLECTION_NO_MANIFEST, 1021, LCB_ERROR_TYPE_SDK, 0, "No Collections Manifest") \
173 X(LCB_ERR_COLLECTION_CANNOT_APPLY_MANIFEST, 1022, LCB_ERROR_TYPE_SDK, 0, "Cannot apply collections manifest") \
174 X(LCB_ERR_AUTH_CONTINUE, 1023, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_FATAL, "Error code used internally within libcouchbase for SASL auth. Should not be visible from the API") \
175 X(LCB_ERR_CONNECTION_REFUSED, 1024, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_NETWORK | LCB_ERROR_FLAG_TRANSIENT, "The remote host refused the connection") \
176 X(LCB_ERR_SOCKET_SHUTDOWN, 1025, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_NETWORK | LCB_ERROR_FLAG_TRANSIENT, "The remote host closed the connection") \
177 X(LCB_ERR_CONNECTION_RESET, 1026, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_NETWORK | LCB_ERROR_FLAG_TRANSIENT, "The connection was forcibly reset by the remote host") \
178 X(LCB_ERR_CANNOT_GET_PORT, 1027, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_NETWORK | LCB_ERROR_FLAG_FATAL, "Could not assign a local port for this socket. For client sockets this means there are too many TCP sockets open") \
179 X(LCB_ERR_INCOMPLETE_PACKET, 1028, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_INPUT | LCB_ERROR_FLAG_TRANSIENT, "Incomplete packet was passed to forward function") \
180 X(LCB_ERR_SDK_FEATURE_UNAVAILABLE, 1029, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_INPUT, "The requested feature is not supported by the client, either because of settings in the configured instance, or because of options disabled at the time the library was compiled") \
181 X(LCB_ERR_OPTIONS_CONFLICT, 1030, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_INPUT, "The operation structure contains conflicting options") \
182 X(LCB_ERR_KVENGINE_INVALID_PACKET, 1031, LCB_ERROR_TYPE_SDK, 0, "A badly formatted packet was sent to the server. Please report this in a bug") \
183 X(LCB_ERR_DURABILITY_TOO_MANY, 1032, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_INPUT, "Durability constraints requires more nodes/replicas than the cluster configuration allows. Durability constraints will never be satisfied") \
184 X(LCB_ERR_SHEDULE_FAILURE, 1033, LCB_ERROR_TYPE_SDK, 0, "Internal error used for destroying unscheduled command data") \
185 X(LCB_ERR_DURABILITY_NO_MUTATION_TOKENS, 1034, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_INPUT, "The given item does not have a mutation token associated with it. this is either because fetching mutation tokens was not enabled, or you are trying to check on something not stored by this instance") \
186 X(LCB_ERR_SASLMECH_UNAVAILABLE, 1035, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_INPUT | LCB_ERROR_FLAG_FATAL, "The requested SASL mechanism was not supported by the server. Either upgrade the server or change the mechanism requirements") \
187 X(LCB_ERR_TOO_MANY_REDIRECTS, 1036, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_NETWORK, "Maximum allowed number of redirects reached. See lcb_cntl and the LCB_CNTL_MAX_REDIRECTS option to modify this limit") \
188 X(LCB_ERR_MAP_CHANGED, 1037, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_TRANSIENT, "The cluster map has changed and this operation could not be completed or retried internally. Try this operation again") \
189 X(LCB_ERR_NOT_MY_VBUCKET, 1038, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_NETWORK | LCB_ERROR_FLAG_TRANSIENT, "The server which received this command claims it is not hosting this key") \
190 X(LCB_ERR_UNKNOWN_SUBDOC_COMMAND, 1039, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_INPUT, "Unknown subdocument command") \
191 X(LCB_ERR_KVENGINE_UNKNOWN_ERROR, 1040, LCB_ERROR_TYPE_SDK, 0, "The server replied with an unrecognized status code. A newer version of this library may be able to decode it") \
192 X(LCB_ERR_NAMESERVER, 1041, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_NETWORK, "Invalid reply received from nameserver") \
193 X(LCB_ERR_INVALID_RANGE, 1042, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_INPUT, "Invalid range") \
194 X(LCB_ERR_NOT_STORED, 1043, LCB_ERROR_TYPE_SDK, 0, "Item not stored (did you try to append/prepend to a missing key?)") \
195 X(LCB_ERR_BUSY, 1044, LCB_ERROR_TYPE_SDK, 0, "Busy. This is an internal error") \
196 X(LCB_ERR_SDK_INTERNAL, 1045, LCB_ERROR_TYPE_SDK, 0, "Internal libcouchbase error") \
197 X(LCB_ERR_INVALID_DELTA, 1046, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_INPUT, "The value requested to be incremented is not stored as a number") \
198 X(LCB_ERR_NO_COMMANDS, 1047, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_INPUT, "No commands specified") \
199 X(LCB_ERR_NETWORK, 1048, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_NETWORK, "Generic network failure") \
200 X(LCB_ERR_UNKNOWN_HOST, 1049, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_INPUT | LCB_ERROR_FLAG_NETWORK, "DNS/Hostname lookup failed") \
201 X(LCB_ERR_PROTOCOL_ERROR, 1050, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_NETWORK, "Data received on socket was not in the expected format") \
202 X(LCB_ERR_CONNECT_ERROR, 1051, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_NETWORK, "Error while establishing TCP connection") \
203 X(LCB_ERR_EMPTY_KEY, 1052, LCB_ERROR_TYPE_SDK, LCB_ERROR_FLAG_INPUT, "An empty key was passed to an operation") \
204 X(LCB_ERR_HTTP, 1053, LCB_ERROR_TYPE_SDK, 0, "HTTP Operation failed. Inspect status code for details") \
205 X(LCB_ERR_QUERY, 1054, LCB_ERROR_TYPE_SDK, 0, "Query execution failed. Inspect raw response object for information") \
206 X(LCB_ERR_TOPOLOGY_CHANGE, 1055, LCB_ERROR_TYPE_SDK, 0, "Topology Change (internal)")
207 /* clang-format on */
208 
210 typedef enum {
211 #define X(n, v, cls, f, s) n = v,
212  LCB_XERROR(X)
213 #undef X
214 
217 } lcb_STATUS;
218 
220 #define LCB_ERROR_IS_NETWORK(e) ((lcb_error_flags(e) & LCB_ERROR_FLAG_NETWORK) == LCB_ERROR_FLAG_NETWORK)
221 #define LCB_ERROR_IS_SUBDOC(e) ((lcb_error_flags(e) & LCB_ERROR_FLAG_SUBDOC) == LCB_ERROR_FLAG_SUBDOC)
222 #define LCB_ERROR_IS_TRANSIENT(e) ((lcb_error_flags(e) & LCB_ERROR_FLAG_TRANSIENT) == LCB_ERROR_FLAG_TRANSIENT)
223 #define LCB_ERROR_IS_FATAL(e) ((lcb_error_flags(e) & LCB_ERROR_FLAG_FATAL) == LCB_ERROR_FLAG_FATAL)
224 #define LCB_ERROR_IS_INPUT(e) ((lcb_error_flags(e) & LCB_ERROR_FLAG_INPUT) == LCB_ERROR_FLAG_INPUT)
225 
226 typedef struct lcb_KEY_VALUE_ERROR_CONTEXT_ lcb_KEY_VALUE_ERROR_CONTEXT;
227 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_kv_rc(const lcb_KEY_VALUE_ERROR_CONTEXT *ctx);
228 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_kv_status_code(const lcb_KEY_VALUE_ERROR_CONTEXT *ctx, uint16_t *status_code);
229 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_kv_opaque(const lcb_KEY_VALUE_ERROR_CONTEXT *ctx, uint32_t *opaque);
230 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_kv_cas(const lcb_KEY_VALUE_ERROR_CONTEXT *ctx, uint64_t *cas);
231 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_kv_key(const lcb_KEY_VALUE_ERROR_CONTEXT *ctx, const char **key,
232  size_t *key_len);
233 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_kv_bucket(const lcb_KEY_VALUE_ERROR_CONTEXT *ctx, const char **bucket,
234  size_t *bucket_len);
235 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_kv_collection(const lcb_KEY_VALUE_ERROR_CONTEXT *ctx, const char **collection,
236  size_t *collection_len);
237 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_kv_scope(const lcb_KEY_VALUE_ERROR_CONTEXT *ctx, const char **scope,
238  size_t *scope_len);
239 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_kv_context(const lcb_KEY_VALUE_ERROR_CONTEXT *ctx, const char **context,
240  size_t *context_len);
241 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_kv_ref(const lcb_KEY_VALUE_ERROR_CONTEXT *ctx, const char **ref,
242  size_t *ref_len);
243 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_kv_endpoint(const lcb_KEY_VALUE_ERROR_CONTEXT *ctx, const char **endpoint,
244  size_t *endpoint_len);
245 
246 typedef struct lcb_QUERY_ERROR_CONTEXT_ lcb_QUERY_ERROR_CONTEXT;
247 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_query_rc(const lcb_QUERY_ERROR_CONTEXT *ctx);
248 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_query_first_error_code(const lcb_QUERY_ERROR_CONTEXT *ctx, uint32_t *code);
249 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_query_first_error_message(const lcb_QUERY_ERROR_CONTEXT *ctx,
250  const char **message, size_t *message_len);
251 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_query_statement(const lcb_QUERY_ERROR_CONTEXT *ctx, const char **statement,
252  size_t *statement_len);
253 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_query_client_context_id(const lcb_QUERY_ERROR_CONTEXT *ctx, const char **id,
254  size_t *id_len);
255 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_query_query_params(const lcb_QUERY_ERROR_CONTEXT *ctx, const char **params,
256  size_t *params_len);
257 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_query_http_response_code(const lcb_QUERY_ERROR_CONTEXT *ctx, uint32_t *code);
258 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_query_http_response_body(const lcb_QUERY_ERROR_CONTEXT *ctx, const char **body,
259  size_t *body_len);
260 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_query_endpoint(const lcb_QUERY_ERROR_CONTEXT *ctx, const char **endpoint,
261  size_t *endpoint_len);
262 
263 typedef struct lcb_ANALYTICS_ERROR_CONTEXT_ lcb_ANALYTICS_ERROR_CONTEXT;
264 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_analytics_rc(const lcb_ANALYTICS_ERROR_CONTEXT *ctx);
265 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_analytics_first_error_code(const lcb_ANALYTICS_ERROR_CONTEXT *ctx,
266  uint32_t *code);
267 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_analytics_first_error_message(const lcb_ANALYTICS_ERROR_CONTEXT *ctx,
268  const char **message, size_t *message_len);
269 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_analytics_statement(const lcb_ANALYTICS_ERROR_CONTEXT *ctx,
270  const char **statement, size_t *statement_len);
271 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_analytics_query_params(const lcb_ANALYTICS_ERROR_CONTEXT *ctx,
272  const char **query_params, size_t *query_params_len);
273 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_analytics_client_context_id(const lcb_ANALYTICS_ERROR_CONTEXT *ctx,
274  const char **id, size_t *id_len);
275 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_analytics_http_response_code(const lcb_ANALYTICS_ERROR_CONTEXT *ctx,
276  uint32_t *code);
277 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_analytics_http_response_body(const lcb_ANALYTICS_ERROR_CONTEXT *ctx,
278  const char **body, size_t *body_len);
279 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_analytics_endpoint(const lcb_ANALYTICS_ERROR_CONTEXT *ctx, const char **endpoint,
280  size_t *endpoint_len);
281 
282 typedef struct lcb_VIEW_ERROR_CONTEXT_ lcb_VIEW_ERROR_CONTEXT;
283 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_view_rc(const lcb_VIEW_ERROR_CONTEXT *ctx);
284 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_view_first_error_code(const lcb_VIEW_ERROR_CONTEXT *ctx, const char **code,
285  size_t *code_len);
286 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_view_first_error_message(const lcb_VIEW_ERROR_CONTEXT *ctx, const char **message,
287  size_t *message_len);
288 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_view_design_document(const lcb_VIEW_ERROR_CONTEXT *ctx, const char **name,
289  size_t *name_len);
290 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_view_view(const lcb_VIEW_ERROR_CONTEXT *ctx, const char **name,
291  size_t *name_len);
292 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_view_query_params(const lcb_VIEW_ERROR_CONTEXT *ctx, const char **params,
293  size_t *params_len);
294 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_view_http_response_code(const lcb_VIEW_ERROR_CONTEXT *ctx, uint32_t *code);
295 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_view_http_response_body(const lcb_VIEW_ERROR_CONTEXT *ctx, const char **body,
296  size_t *body_len);
297 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_view_endpoint(const lcb_VIEW_ERROR_CONTEXT *ctx, const char **endpoint,
298  size_t *endpoint_len);
299 
300 typedef struct lcb_SEARCH_ERROR_CONTEXT_ lcb_SEARCH_ERROR_CONTEXT;
301 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_search_rc(const lcb_SEARCH_ERROR_CONTEXT *ctx);
302 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_search_error_message(const lcb_SEARCH_ERROR_CONTEXT *ctx, const char **message,
303  size_t *message_len);
304 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_search_index_name(const lcb_SEARCH_ERROR_CONTEXT *ctx, const char **name,
305  size_t *name_len);
306 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_search_query(const lcb_SEARCH_ERROR_CONTEXT *ctx, const char **query,
307  size_t *query_len);
308 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_search_params(const lcb_SEARCH_ERROR_CONTEXT *ctx, const char **params,
309  size_t *params_len);
310 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_search_http_response_code(const lcb_SEARCH_ERROR_CONTEXT *ctx, uint32_t *code);
311 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_search_http_response_body(const lcb_SEARCH_ERROR_CONTEXT *ctx, const char **body,
312  size_t *body_len);
313 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_search_endpoint(const lcb_SEARCH_ERROR_CONTEXT *ctx, const char **endpoint,
314  size_t *endpoint_len);
315 
316 typedef struct lcb_HTTP_ERROR_CONTEXT_ lcb_HTTP_ERROR_CONTEXT;
317 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_http_rc(const lcb_HTTP_ERROR_CONTEXT *ctx);
318 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_http_path(const lcb_HTTP_ERROR_CONTEXT *ctx, const char **path,
319  size_t *path_len);
320 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_http_response_code(const lcb_HTTP_ERROR_CONTEXT *ctx, uint32_t *code);
321 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_http_response_body(const lcb_HTTP_ERROR_CONTEXT *ctx, const char **body,
322  size_t *body_len);
323 LIBCOUCHBASE_API lcb_STATUS lcb_errctx_http_endpoint(const lcb_HTTP_ERROR_CONTEXT *ctx, const char **endpoint,
324  size_t *endpoint_len);
325 
332 LIBCOUCHBASE_API
333 uint32_t lcb_error_flags(lcb_STATUS err);
334 
339 LCB_INTERNAL_API
340 const char *lcb_strerror_short(lcb_STATUS error);
341 
345 LCB_INTERNAL_API
346 const char *lcb_strerror_long(lcb_STATUS error);
347 
353 LIBCOUCHBASE_API
354 lcb_STATUS lcb_errmap_default(lcb_INSTANCE *instance, lcb_U16 code);
355 
364 typedef lcb_STATUS (*lcb_errmap_callback)(lcb_INSTANCE *instance, lcb_U16 bincode);
365 
367 LIBCOUCHBASE_API
369 
370 /* clang-format off */
371 #define LCB_XRETRY_REASON(X) \
372  /* name, code, non_idempotent_retry, always_retry */ \
373  X(LCB_RETRY_REASON_UNKNOWN, 0, 0, 0) \
374  X(LCB_RETRY_REASON_SOCKET_NOT_AVAILABLE, 1, 1, 0) \
375  X(LCB_RETRY_REASON_SERVICE_NOT_AVAILABLE, 2, 1, 0) \
376  X(LCB_RETRY_REASON_NODE_NOT_AVAILABLE, 3, 1, 0) \
377  X(LCB_RETRY_REASON_KV_NOT_MY_VBUCKET, 4, 1, 1) \
378  X(LCB_RETRY_REASON_KV_COLLECTION_OUTDATED, 5, 1, 1) \
379  X(LCB_RETRY_REASON_KV_ERROR_MAP_RETRY_INDICATED, 6, 1, 0) \
380  X(LCB_RETRY_REASON_KV_LOCKED, 7, 1, 0) \
381  X(LCB_RETRY_REASON_KV_TEMPORARY_FAILURE, 8, 1, 0) \
382  X(LCB_RETRY_REASON_KV_SYNC_WRITE_IN_PROGRESS, 9, 1, 0) \
383  X(LCB_RETRY_REASON_KV_SYNC_WRITE_RE_COMMIT_IN_PROGRESS, 10, 1, 0) \
384  X(LCB_RETRY_REASON_SERVICE_RESPONSE_CODE_INDICATED, 11, 1, 0) \
385  X(LCB_RETRY_REASON_SOCKET_CLOSED_WHILE_IN_FLIGHT, 12, 0, 0) \
386  X(LCB_RETRY_REASON_CIRCUIT_BREAKER_OPEN, 13, 1, 0) \
387  X(LCB_RETRY_REASON_QUERY_PREPARED_STATEMENT_FAILURE, 14, 1, 0) \
388  X(LCB_RETRY_REASON_ANALYTICS_TEMPORARY_FAILURE, 15, 1, 0) \
389  X(LCB_RETRY_REASON_SEARCH_TOO_MANY_REQUESTS, 16, 1, 0)
390 /* clang-format on */
391 
392 typedef enum {
393 #define X(n, c, nir, ar) n = c,
394  LCB_XRETRY_REASON(X)
395 #undef X
396 } lcb_RETRY_REASON;
397 
398 typedef struct lcb_RETRY_REQUEST_ lcb_RETRY_REQUEST;
399 
400 LIBCOUCHBASE_API int lcb_retry_reason_allows_non_idempotent_retry(lcb_RETRY_REASON code);
401 LIBCOUCHBASE_API int lcb_retry_reason_is_always_retry(lcb_RETRY_REASON code);
402 
403 LIBCOUCHBASE_API int lcb_retry_request_is_idempotent(lcb_RETRY_REQUEST *req);
404 LIBCOUCHBASE_API int lcb_retry_request_retry_attempts(lcb_RETRY_REQUEST *req);
405 LIBCOUCHBASE_API void *lcb_retry_request_operation_cookie(lcb_RETRY_REQUEST *req);
406 
407 typedef struct {
408  uint32_t should_retry;
409  uint32_t retry_after_ms;
410 } lcb_RETRY_ACTION;
411 
412 typedef lcb_RETRY_ACTION (*lcb_RETRY_STRATEGY)(lcb_RETRY_REQUEST *req, lcb_RETRY_REASON reason);
413 
440 LIBCOUCHBASE_API lcb_STATUS lcb_retry_strategy(lcb_INSTANCE *instance, lcb_RETRY_STRATEGY strategy);
441 
442 #ifdef __cplusplus
443 }
444 #endif
445 
446 #endif
lcb_STATUS lcb_errmap_default(lcb_INSTANCE *instance, lcb_U16 code)
This may be used in conjunction with the errmap callback if it wishes to fallback for default behav...
lcb_errmap_callback lcb_set_errmap_callback(lcb_INSTANCE *instance, lcb_errmap_callback)
The errors below this value reserved for libcouchbase usage.
Definition: error.h:216
lcb_STATUS
Error codes returned by the library.
Definition: error.h:210
LCB_INTERNAL_API const char * lcb_strerror_long(lcb_STATUS error)
Get a longer textual description of an error message.
lcb_STATUS lcb_retry_strategy(lcb_INSTANCE *instance, lcb_RETRY_STRATEGY strategy)
Set the global retry strategy.
struct lcb_st lcb_INSTANCE
Library handle representing a connection to a cluster and its data buckets.
Definition: couchbase.h:35
uint32_t lcb_error_flags(lcb_STATUS err)
Get error categories for a specific code
lcb_STATUS(* lcb_errmap_callback)(lcb_INSTANCE *instance, lcb_U16 bincode)
Callback for error mappings.
Definition: error.h:366
LCB_INTERNAL_API const char * lcb_strerror_short(lcb_STATUS error)
Get a shorter textual description of an error message.