Couchbase C Client  2.4.4
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 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 
30 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
51 typedef enum {
54 
57 
60 
63 
66 
69 
72 
75 
79 
89 #define LCB_XERR(X) \
90  \
91  X(LCB_SUCCESS, 0x00, 0, "Success (Not an error)") \
92  \
93  X(LCB_AUTH_CONTINUE, 0x01, LCB_ERRTYPE_INTERNAL|LCB_ERRTYPE_FATAL|LCB_ERRTYPE_SRVGEN, \
94  "Error code used internally within libcouchbase for SASL auth. Should " \
95  "not be visible from the API") \
96  \
97  \
104  X(LCB_AUTH_ERROR, 0x02, LCB_ERRTYPE_FATAL|LCB_ERRTYPE_INPUT, \
105  "Authentication failed. You may have provided an invalid " \
106  "username/password combination") \
107  \
108  \
111  X(LCB_DELTA_BADVAL, 0x03, LCB_ERRTYPE_INPUT|LCB_ERRTYPE_DATAOP|LCB_ERRTYPE_SRVGEN, \
112  "The value requested to be incremented is not stored as a number") \
113  \
114  \
117  X(LCB_E2BIG, 0x04, LCB_ERRTYPE_INPUT|LCB_ERRTYPE_DATAOP|LCB_ERRTYPE_SRVGEN, \
118  "The object requested is too big to store in the server") \
119  \
120  X(LCB_EBUSY, 0x05, LCB_ERRTYPE_TRANSIENT, "The server is busy. Try again later") \
121  \
122  X(LCB_EINTERNAL, 0x06, LCB_ERRTYPE_INTERNAL, "Internal libcouchbase error") \
123  \
124  \
127  X(LCB_EINVAL, 0x07, LCB_ERRTYPE_INPUT, "Invalid input/arguments") \
128  \
129  \
131  X(LCB_ENOMEM, 0x08, LCB_ERRTYPE_TRANSIENT, \
132  "The server is out of memory. Try again later") \
133  \
134  X(LCB_ERANGE, 0x09, LCB_ERRTYPE_INPUT|LCB_ERRTYPE_DATAOP|LCB_ERRTYPE_SRVGEN, \
135  "Invalid range") \
136  \
137  \
138  X(LCB_ERROR, 0x0A, 0, "Generic error") \
139  \
140  \
146  X(LCB_ETMPFAIL, 0x0B, LCB_ERRTYPE_TRANSIENT|LCB_ERRTYPE_SRVLOAD|LCB_ERRTYPE_SRVGEN, \
147  "Temporary failure received from server. Try again later") \
148  \
149  \
153  X(LCB_KEY_EEXISTS, 0x0C, LCB_ERRTYPE_DATAOP|LCB_ERRTYPE_SRVGEN, \
154  "The key already exists in the server. If you have supplied a CAS then " \
155  "the key exists with a CAS value different than specified") \
156  \
157  \
158  X(LCB_KEY_ENOENT, 0x0D, LCB_ERRTYPE_DATAOP|LCB_ERRTYPE_SRVGEN, \
159  "The key does not exist on the server") \
160  \
161  \
162  X(LCB_DLOPEN_FAILED, 0x0E, LCB_ERRTYPE_INPUT|LCB_ERRTYPE_FATAL|LCB_ERRTYPE_PLUGIN, \
163  "Could not locate plugin library") \
164  \
165  \
166  X(LCB_DLSYM_FAILED, 0x0F, LCB_ERRTYPE_INPUT|LCB_ERRTYPE_FATAL|LCB_ERRTYPE_PLUGIN, \
167  "Required plugin initializer not found") \
168  \
169  \
175  X(LCB_NETWORK_ERROR, 0x10, LCB_ERRTYPE_NETWORK, "Network failure") \
176  \
177  \
180  X(LCB_NOT_MY_VBUCKET, 0x11, LCB_ERRTYPE_NETWORK|LCB_ERRTYPE_TRANSIENT|LCB_ERRTYPE_SRVGEN, \
181  "The server which received this command claims it is not hosting this key") \
182  \
183  \
185  X(LCB_NOT_STORED, 0x12, LCB_ERRTYPE_DATAOP|LCB_ERRTYPE_SRVGEN, \
186  "Item not stored (did you try to append/prepend to a missing key?)") \
187  \
188  \
195  X(LCB_NOT_SUPPORTED, 0x13, 0, "Operation not supported") \
196  \
197  \
199  X(LCB_UNKNOWN_COMMAND, 0x14, LCB_ERRTYPE_SRVGEN, "Unknown command") \
200  \
201  \
206  X(LCB_UNKNOWN_HOST, 0x15, LCB_ERRTYPE_NETWORK|LCB_ERRTYPE_INPUT, \
207  "DNS/Hostname lookup failed") \
208  \
209  \
210  X(LCB_PROTOCOL_ERROR, 0x16, LCB_ERRTYPE_NETWORK, \
211  "Data received on socket was not in the expected format") \
212  \
213  \
216  X(LCB_ETIMEDOUT, 0x17, LCB_ERRTYPE_NETWORK|LCB_ERRTYPE_TRANSIENT, \
217  "Client-Side timeout exceeded for operation. Inspect network conditions " \
218  "or increase the timeout") \
219  \
220  \
221  X(LCB_CONNECT_ERROR, 0x18, LCB_ERRTYPE_NETWORK, \
222  "Error while establishing TCP connection") \
223  \
224  \
226  X(LCB_BUCKET_ENOENT, 0x19, LCB_ERRTYPE_INPUT|LCB_ERRTYPE_FATAL, \
227  "The bucket requested does not exist") \
228  \
229  \
230  X(LCB_CLIENT_ENOMEM, 0x1A, LCB_ERRTYPE_FATAL, \
231  "Memory allocation for libcouchbase failed. Severe problems ahead") \
232  \
233  \
235  X(LCB_CLIENT_ETMPFAIL, 0x1B, LCB_ERRTYPE_TRANSIENT, \
236  "Temporary failure on the client side. Did you call lcb_connect?") \
237  \
238  X(LCB_EBADHANDLE, 0x1C, LCB_ERRTYPE_INPUT, \
239  "Bad handle type for operation. " \
240  "You cannot perform administrative operations on a data handle, or data "\
241  "operations on a cluster handle") \
242  \
243  X(LCB_SERVER_BUG, 0x1D, 0, "Encountered a server bug") \
244  \
245  X(LCB_PLUGIN_VERSION_MISMATCH, 0x1E, LCB_ERRTYPE_INPUT|LCB_ERRTYPE_FATAL|LCB_ERRTYPE_PLUGIN, \
246  "This version of libcouchbase cannot load the specified plugin") \
247  \
248  X(LCB_INVALID_HOST_FORMAT, 0x1F, LCB_ERRTYPE_INPUT, \
249  "Hostname specified for URI is in an invalid format") \
250  \
251  X(LCB_INVALID_CHAR, 0x20, LCB_ERRTYPE_INPUT, "Illegal characted") \
252  \
253  \
256  X(LCB_DURABILITY_ETOOMANY, 0x21, LCB_ERRTYPE_INPUT, \
257  "Durability constraints requires more nodes/replicas than the cluster "\
258  "configuration allows. Durability constraints will never be satisfied") \
259  \
260  X(LCB_DUPLICATE_COMMANDS, 0x22, LCB_ERRTYPE_INPUT, \
261  "The same key was specified more than once in the command list") \
262  \
263  \
266  X(LCB_NO_MATCHING_SERVER, 0x23, LCB_ERRTYPE_TRANSIENT, \
267  "No node was found for servicing this key. This may be a result of a " \
268  "nonexistent/stale cluster configuration") \
269  \
270  \
274  X(LCB_BAD_ENVIRONMENT, 0x24, LCB_ERRTYPE_FATAL|LCB_ERRTYPE_INPUT, \
275  "The value for an environment variable recognized by libcouchbase was " \
276  "specified in an incorrect format. Check your environment for entries " \
277  "starting with 'LCB_' or 'LIBCOUCHBASE_'") \
278  \
279  X(LCB_BUSY, 0x25, LCB_ERRTYPE_INTERNAL, "Busy. This is an internal error") \
280  \
281  \
282  X(LCB_INVALID_USERNAME, 0x26, LCB_ERRTYPE_INPUT|LCB_ERRTYPE_FATAL, \
283  "The administrative account can no longer be used for data access") \
284  \
285  X(LCB_CONFIG_CACHE_INVALID, 0x27, LCB_ERRTYPE_INPUT, \
286  "The contents of the configuration cache file were invalid. Configuration " \
287  "will be fetched from the network") \
288  \
289  \
292  X(LCB_SASLMECH_UNAVAILABLE, 0x28, LCB_ERRTYPE_INPUT|LCB_ERRTYPE_FATAL, \
293  "The requested SASL mechanism was not supported by the server. Either " \
294  "upgrade the server or change the mechanism requirements") \
295  \
296  \
298  X(LCB_TOO_MANY_REDIRECTS, 0x29, LCB_ERRTYPE_NETWORK, \
299  "Maximum allowed number of redirects reached. See lcb_cntl and the "\
300  "LCB_CNTL_MAX_REDIRECTS option to modify this limit") \
301  \
302  \
307  X(LCB_MAP_CHANGED, 0x2A, LCB_ERRTYPE_NETWORK|LCB_ERRTYPE_TRANSIENT, \
308  "The cluster map has changed and this operation could not be completed " \
309  "or retried internally. Try this operation again") \
310  \
311  \
313  X(LCB_INCOMPLETE_PACKET, 0x2B, LCB_ERRTYPE_TRANSIENT|LCB_ERRTYPE_INPUT, \
314  "Incomplete packet was passed to forward function") \
315  \
316  \
319  X(LCB_ECONNREFUSED, 0x2C, LCB_ERRTYPE_NETWORK|LCB_ERRTYPE_TRANSIENT, \
320  "The remote host refused the connection. Is the service up?") \
321  \
322  \
326  X(LCB_ESOCKSHUTDOWN, 0x2D, LCB_ERRTYPE_NETWORK|LCB_ERRTYPE_TRANSIENT, \
327  "The remote host closed the connection") \
328  \
329  \
333  X(LCB_ECONNRESET, 0x2E, LCB_ERRTYPE_NETWORK|LCB_ERRTYPE_TRANSIENT, \
334  "The connection was forcibly reset by the remote host") \
335  \
336  \
344  X(LCB_ECANTGETPORT, 0x2F, LCB_ERRTYPE_NETWORK|LCB_ERRTYPE_FATAL, \
345  "Could not assign a local port for this socket. For client sockets this means " \
346  "there are too many TCP sockets open") \
347  \
348  \
355  X(LCB_EFDLIMITREACHED, 0x30, LCB_ERRTYPE_NETWORK|LCB_ERRTYPE_FATAL, \
356  "The system or process has reached its maximum number of file descriptors") \
357  \
358  \
362  X(LCB_ENETUNREACH, 0x31, LCB_ERRTYPE_NETWORK|LCB_ERRTYPE_TRANSIENT, \
363  "The remote host was unreachable - is your network OK?") \
364  \
365  \
367  X(LCB_ECTL_UNKNOWN, 0x32, LCB_ERRTYPE_INPUT, \
368  "Control code passed was unrecognized") \
369  \
370  \
376  X(LCB_ECTL_UNSUPPMODE, 0x33, LCB_ERRTYPE_INPUT, \
377  "Invalid modifier for cntl operation (e.g. tried to read a write-only value") \
378  \
379  \
384  X(LCB_ECTL_BADARG, 0x34, LCB_ERRTYPE_INPUT, \
385  "Argument passed to cntl was badly formatted") \
386  \
387  \
389  X(LCB_EMPTY_KEY, 0x35, LCB_ERRTYPE_INPUT, \
390  "An empty key was passed to an operation") \
391  \
392  \
396  X(LCB_SSL_ERROR, 0x36, LCB_ERRTYPE_FATAL, \
397  "A generic error related to the SSL subsystem was encountered. Enable logging " \
398  "to see more details") \
399  \
400  \
403  X(LCB_SSL_CANTVERIFY, 0x37, LCB_ERRTYPE_FATAL, \
404  "Client could not verify server's certificate") \
405  \
406  X(LCB_SCHEDFAIL_INTERNAL, 0x38, 0, \
407  "Internal error used for destroying unscheduled command data") \
408  \
409  \
414  X(LCB_CLIENT_FEATURE_UNAVAILABLE, 0x39, LCB_ERRTYPE_INPUT, \
415  "The requested feature is not supported by the client, either because of " \
416  "settings in the configured instance, or because of options disabled at " \
417  "the time the library was compiled") \
418  \
419  \
421  X(LCB_OPTIONS_CONFLICT, 0x3A, LCB_ERRTYPE_INPUT, \
422  "The operation structure contains conflicting options")
423 
425 typedef enum {
426  #define X(n, v, cls, s) n = v,
428  #undef X
429 
430  #ifdef LIBCOUCHBASE_INTERNAL
431 
434  LCB_MAX_ERROR_VAL,
435  #endif
436 
437  /* The errors below this value reserver for libcouchbase usage. */
438  LCB_MAX_ERROR = 0x1000
439 } lcb_error_t;
440 
442 #define LCB_EIFINPUT(e) (lcb_get_errtype(e) & LCB_ERRTYPE_INPUT)
443 
445 #define LCB_EIFNET(e) (lcb_get_errtype(e) & LCB_ERRTYPE_NETWORK)
446 
448 #define LCB_EIFFATAL(e) (lcb_get_errtype(e) & LCB_ERRTYPE_FATAL)
449 
451 #define LCB_EIFTMP(e) (lcb_get_errtype(e) & LCB_ERRTYPE_TRANSIENT)
452 
454 #define LCB_EIFDATA(e) (lcb_get_errtype(e) & LCB_ERRTYPE_DATAOP)
455 
457 #define LCB_EIFPLUGIN(e) (lcb_get_errtype(e) & LCB_ERRTYPE_PLUGIN)
458 #define LCB_EIFSRVLOAD(e) (lcb_get_errtype(e) & LCB_ERRTYPE_SRVLOAD)
459 #define LCB_EIFSRVGEN(e) (lcb_get_errtype(e) & LCB_ERRTYPE_SRVGEN)
460 
467 LIBCOUCHBASE_API
469 
479 LIBCOUCHBASE_API
480 const char *lcb_strerror(lcb_t instance, lcb_error_t error);
481 
482 #ifdef __cplusplus
483 }
484 #endif
485 
486 #endif
const char * lcb_strerror(lcb_t instance, lcb_error_t error)
Get a textual descrtiption for the given error code.
int lcb_get_errtype(lcb_error_t err)
Get error categories for a specific code.
Error code indicating the server generated this message.
Definition: error.h:77
Error codes which should never be visible to the user.
Definition: error.h:68
lcb_errflags_t
Error Categories.
Definition: error.h:51
Error type indicating a fatal condition within the server or library.
Definition: error.h:59
Error type indicating a likely network failure.
Definition: error.h:56
Error code indicating the server is under load.
Definition: error.h:74
lcb_error_t
Error codes returned by the library.
Definition: error.h:425
Error type indicating a transient condition within the server.
Definition: error.h:62
Error code indicating a plugin failure.
Definition: error.h:71
Error type indicating a likely issue in user input.
Definition: error.h:53
Error type indicating a negative server reply for the data.
Definition: error.h:65
#define LCB_XERR(X)
XMacro for all error types.
Definition: error.h:89