Couchbase C Client  2.5.6
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 
78 
87 
88 /* PRIVATE. This is just here to instruct/inform users to use the more detailed codes */
89 #define LCB__ERR_USEDETAILS \
90  "Enable detailed error codes (via LCB_CNTL_DETAILED_ERRCODES, or via " \
91  "`detailed_errcodes` in the connection string) and/or enable logging to " \
92  "get more information"
93 
103 #define LCB_XERR(X) \
104  \
105  X(LCB_SUCCESS, 0x00, 0, "Success (Not an error)") \
106  \
107  X(LCB_AUTH_CONTINUE, 0x01, LCB_ERRTYPE_INTERNAL|LCB_ERRTYPE_FATAL|LCB_ERRTYPE_SRVGEN, \
108  "Error code used internally within libcouchbase for SASL auth. Should " \
109  "not be visible from the API") \
110  \
111  \
118  X(LCB_AUTH_ERROR, 0x02, LCB_ERRTYPE_FATAL|LCB_ERRTYPE_INPUT, \
119  "Authentication failed. You may have provided an invalid " \
120  "username/password combination") \
121  \
122  \
125  X(LCB_DELTA_BADVAL, 0x03, LCB_ERRTYPE_INPUT|LCB_ERRTYPE_DATAOP|LCB_ERRTYPE_SRVGEN, \
126  "The value requested to be incremented is not stored as a number") \
127  \
128  \
131  X(LCB_E2BIG, 0x04, LCB_ERRTYPE_INPUT|LCB_ERRTYPE_DATAOP|LCB_ERRTYPE_SRVGEN, \
132  "The object requested is too big to store in the server") \
133  \
134  X(LCB_EBUSY, 0x05, LCB_ERRTYPE_TRANSIENT, "The server is busy. Try again later") \
135  \
136  X(LCB_EINTERNAL, 0x06, LCB_ERRTYPE_INTERNAL, "Internal libcouchbase error") \
137  \
138  \
141  X(LCB_EINVAL, 0x07, LCB_ERRTYPE_INPUT, "Invalid input/arguments") \
142  \
143  \
145  X(LCB_ENOMEM, 0x08, LCB_ERRTYPE_TRANSIENT, \
146  "The server is out of memory. Try again later") \
147  \
148  X(LCB_ERANGE, 0x09, LCB_ERRTYPE_INPUT|LCB_ERRTYPE_DATAOP|LCB_ERRTYPE_SRVGEN, \
149  "Invalid range") \
150  \
151  \
152  X(LCB_ERROR, 0x0A, 0, "Generic error") \
153  \
154  \
160  X(LCB_ETMPFAIL, 0x0B, LCB_ERRTYPE_TRANSIENT|LCB_ERRTYPE_SRVLOAD|LCB_ERRTYPE_SRVGEN, \
161  "Temporary failure received from server. Try again later") \
162  \
163  \
167  X(LCB_KEY_EEXISTS, 0x0C, LCB_ERRTYPE_DATAOP|LCB_ERRTYPE_SRVGEN, \
168  "The key already exists in the server. If you have supplied a CAS then " \
169  "the key exists with a CAS value different than specified") \
170  \
171  \
172  X(LCB_KEY_ENOENT, 0x0D, LCB_ERRTYPE_DATAOP|LCB_ERRTYPE_SRVGEN, \
173  "The key does not exist on the server") \
174  \
175  \
176  X(LCB_DLOPEN_FAILED, 0x0E, LCB_ERRTYPE_INPUT|LCB_ERRTYPE_FATAL|LCB_ERRTYPE_PLUGIN, \
177  "Could not locate plugin library") \
178  \
179  \
180  X(LCB_DLSYM_FAILED, 0x0F, LCB_ERRTYPE_INPUT|LCB_ERRTYPE_FATAL|LCB_ERRTYPE_PLUGIN, \
181  "Required plugin initializer not found") \
182  \
183  \
189  X(LCB_NETWORK_ERROR, 0x10, LCB_ERRTYPE_NETWORK, \
190  "Generic network failure. " LCB__ERR_USEDETAILS) \
191  \
192  \
195  X(LCB_NOT_MY_VBUCKET, 0x11, LCB_ERRTYPE_NETWORK|LCB_ERRTYPE_TRANSIENT|LCB_ERRTYPE_SRVGEN, \
196  "The server which received this command claims it is not hosting this key") \
197  \
198  \
200  X(LCB_NOT_STORED, 0x12, LCB_ERRTYPE_DATAOP|LCB_ERRTYPE_SRVGEN, \
201  "Item not stored (did you try to append/prepend to a missing key?)") \
202  \
203  \
210  X(LCB_NOT_SUPPORTED, 0x13, 0, "Operation not supported") \
211  \
212  \
214  X(LCB_UNKNOWN_COMMAND, 0x14, LCB_ERRTYPE_SRVGEN, "Unknown command") \
215  \
216  \
221  X(LCB_UNKNOWN_HOST, 0x15, LCB_ERRTYPE_NETWORK|LCB_ERRTYPE_INPUT, \
222  "DNS/Hostname lookup failed") \
223  \
224  \
225  X(LCB_PROTOCOL_ERROR, 0x16, LCB_ERRTYPE_NETWORK, \
226  "Data received on socket was not in the expected format") \
227  \
228  \
231  X(LCB_ETIMEDOUT, 0x17, LCB_ERRTYPE_NETWORK|LCB_ERRTYPE_TRANSIENT, \
232  "Client-Side timeout exceeded for operation. Inspect network conditions " \
233  "or increase the timeout") \
234  \
235  \
236  X(LCB_CONNECT_ERROR, 0x18, LCB_ERRTYPE_NETWORK, \
237  "Error while establishing TCP connection. " LCB__ERR_USEDETAILS) \
238  \
239  \
241  X(LCB_BUCKET_ENOENT, 0x19, LCB_ERRTYPE_INPUT|LCB_ERRTYPE_FATAL, \
242  "The bucket requested does not exist") \
243  \
244  \
245  X(LCB_CLIENT_ENOMEM, 0x1A, LCB_ERRTYPE_FATAL, \
246  "Memory allocation for libcouchbase failed. Severe problems ahead") \
247  \
248  \
250  X(LCB_CLIENT_ETMPFAIL, 0x1B, LCB_ERRTYPE_TRANSIENT, \
251  "Temporary failure on the client side. Did you call lcb_connect?") \
252  \
253  X(LCB_EBADHANDLE, 0x1C, LCB_ERRTYPE_INPUT, \
254  "Bad handle type for operation. " \
255  "You cannot perform administrative operations on a data handle, or data "\
256  "operations on a cluster handle") \
257  \
258  X(LCB_SERVER_BUG, 0x1D, 0, "Encountered a server bug") \
259  \
260  X(LCB_PLUGIN_VERSION_MISMATCH, 0x1E, LCB_ERRTYPE_INPUT|LCB_ERRTYPE_FATAL|LCB_ERRTYPE_PLUGIN, \
261  "This version of libcouchbase cannot load the specified plugin") \
262  \
263  X(LCB_INVALID_HOST_FORMAT, 0x1F, LCB_ERRTYPE_INPUT, \
264  "Hostname specified for URI is in an invalid format") \
265  \
266  X(LCB_INVALID_CHAR, 0x20, LCB_ERRTYPE_INPUT, "Illegal characted") \
267  \
268  \
271  X(LCB_DURABILITY_ETOOMANY, 0x21, LCB_ERRTYPE_INPUT, \
272  "Durability constraints requires more nodes/replicas than the cluster "\
273  "configuration allows. Durability constraints will never be satisfied") \
274  \
275  \
278  X(LCB_DUPLICATE_COMMANDS, 0x22, LCB_ERRTYPE_INPUT, \
279  "The same key was specified more than once in the command list") \
280  \
281  \
284  X(LCB_NO_MATCHING_SERVER, 0x23, LCB_ERRTYPE_TRANSIENT, \
285  "The node the request was mapped to does not exist in the current cluster " \
286  "map. This may be the result of a failover.") \
287  \
288  \
292  X(LCB_BAD_ENVIRONMENT, 0x24, LCB_ERRTYPE_FATAL|LCB_ERRTYPE_INPUT, \
293  "The value for an environment variable recognized by libcouchbase was " \
294  "specified in an incorrect format. Check your environment for entries " \
295  "starting with 'LCB_' or 'LIBCOUCHBASE_'") \
296  \
297  X(LCB_BUSY, 0x25, LCB_ERRTYPE_INTERNAL, "Busy. This is an internal error") \
298  \
299  \
300  X(LCB_INVALID_USERNAME, 0x26, LCB_ERRTYPE_INPUT|LCB_ERRTYPE_FATAL, \
301  "The username must match the bucket name (or be NULL) for data access") \
302  \
303  X(LCB_CONFIG_CACHE_INVALID, 0x27, LCB_ERRTYPE_INPUT, \
304  "The contents of the configuration cache file were invalid. Configuration " \
305  "will be fetched from the network") \
306  \
307  \
310  X(LCB_SASLMECH_UNAVAILABLE, 0x28, LCB_ERRTYPE_INPUT|LCB_ERRTYPE_FATAL, \
311  "The requested SASL mechanism was not supported by the server. Either " \
312  "upgrade the server or change the mechanism requirements") \
313  \
314  \
316  X(LCB_TOO_MANY_REDIRECTS, 0x29, LCB_ERRTYPE_NETWORK, \
317  "Maximum allowed number of redirects reached. See lcb_cntl and the "\
318  "LCB_CNTL_MAX_REDIRECTS option to modify this limit") \
319  \
320  \
325  X(LCB_MAP_CHANGED, 0x2A, LCB_ERRTYPE_NETWORK|LCB_ERRTYPE_TRANSIENT, \
326  "The cluster map has changed and this operation could not be completed " \
327  "or retried internally. Try this operation again") \
328  \
329  \
331  X(LCB_INCOMPLETE_PACKET, 0x2B, LCB_ERRTYPE_TRANSIENT|LCB_ERRTYPE_INPUT, \
332  "Incomplete packet was passed to forward function") \
333  \
334  \
337  X(LCB_ECONNREFUSED, 0x2C, LCB_ERRTYPE_NETWORK|LCB_ERRTYPE_TRANSIENT, \
338  "The remote host refused the connection. Is the service up?") \
339  \
340  \
344  X(LCB_ESOCKSHUTDOWN, 0x2D, LCB_ERRTYPE_NETWORK|LCB_ERRTYPE_TRANSIENT, \
345  "The remote host closed the connection") \
346  \
347  \
351  X(LCB_ECONNRESET, 0x2E, LCB_ERRTYPE_NETWORK|LCB_ERRTYPE_TRANSIENT, \
352  "The connection was forcibly reset by the remote host") \
353  \
354  \
362  X(LCB_ECANTGETPORT, 0x2F, LCB_ERRTYPE_NETWORK|LCB_ERRTYPE_FATAL, \
363  "Could not assign a local port for this socket. For client sockets this means " \
364  "there are too many TCP sockets open") \
365  \
366  \
373  X(LCB_EFDLIMITREACHED, 0x30, LCB_ERRTYPE_NETWORK|LCB_ERRTYPE_FATAL, \
374  "The system or process has reached its maximum number of file descriptors") \
375  \
376  \
380  X(LCB_ENETUNREACH, 0x31, LCB_ERRTYPE_NETWORK|LCB_ERRTYPE_TRANSIENT, \
381  "The remote host was unreachable - is your network OK?") \
382  \
383  \
385  X(LCB_ECTL_UNKNOWN, 0x32, LCB_ERRTYPE_INPUT, \
386  "Control code passed was unrecognized") \
387  \
388  \
394  X(LCB_ECTL_UNSUPPMODE, 0x33, LCB_ERRTYPE_INPUT, \
395  "Invalid modifier for cntl operation (e.g. tried to read a write-only value") \
396  \
397  \
402  X(LCB_ECTL_BADARG, 0x34, LCB_ERRTYPE_INPUT, \
403  "Argument passed to cntl was badly formatted") \
404  \
405  \
407  X(LCB_EMPTY_KEY, 0x35, LCB_ERRTYPE_INPUT, \
408  "An empty key was passed to an operation") \
409  \
410  \
414  X(LCB_SSL_ERROR, 0x36, LCB_ERRTYPE_FATAL, \
415  "A generic error related to the SSL subsystem was encountered. Enable logging " \
416  "to see more details") \
417  \
418  \
421  X(LCB_SSL_CANTVERIFY, 0x37, LCB_ERRTYPE_FATAL, \
422  "Client could not verify server's certificate") \
423  \
424  X(LCB_SCHEDFAIL_INTERNAL, 0x38, 0, \
425  "Internal error used for destroying unscheduled command data") \
426  \
427  \
432  X(LCB_CLIENT_FEATURE_UNAVAILABLE, 0x39, LCB_ERRTYPE_INPUT, \
433  "The requested feature is not supported by the client, either because of " \
434  "settings in the configured instance, or because of options disabled at " \
435  "the time the library was compiled") \
436  \
437  \
439  X(LCB_OPTIONS_CONFLICT, 0x3A, LCB_ERRTYPE_INPUT, \
440  "The operation structure contains conflicting options") \
441  \
442  \
444  X(LCB_HTTP_ERROR, 0x3B, 0, \
445  "HTTP Operation failed. Inspect status code for details") \
446  \
447  \
449  X(LCB_DURABILITY_NO_MUTATION_TOKENS, 0x3C, LCB_ERRTYPE_INPUT, \
450  "The given item does not have a mutation token associated with it. " \
451  "this is either because fetching mutation tokens was not enabled, or " \
452  "you are trying to check on something not stored by this instance") \
453  \
454  \
455  X(LCB_UNKNOWN_MEMCACHED_ERROR, 0x3D, LCB_ERRTYPE_SRVGEN, \
456  "The server replied with an unrecognized status code. A newer version " \
457  "of this library may be able to decode it") \
458  \
459  \
460  X(LCB_MUTATION_LOST, 0x3E, LCB_ERRTYPE_SRVGEN,\
461  "The given mutation has been permanently lost due to the node failing " \
462  "before replication") \
463  X(LCB_SUBDOC_PATH_ENOENT, 0x3F, \
464  LCB_ERRTYPE_DATAOP|LCB_ERRTYPE_SRVGEN|LCB_ERRTYPE_SUBDOC, \
465  "Sub-document path does not exist") \
466  X(LCB_SUBDOC_PATH_MISMATCH, 0x40,\
467  LCB_ERRTYPE_DATAOP|LCB_ERRTYPE_SRVGEN|LCB_ERRTYPE_SUBDOC, \
468  "Type of element in sub-document path conflicts with type in document") \
469  X(LCB_SUBDOC_PATH_EINVAL, 0x41, \
470  LCB_ERRTYPE_INPUT|LCB_ERRTYPE_SRVGEN|LCB_ERRTYPE_SUBDOC, \
471  "Malformed sub-document path") \
472  X(LCB_SUBDOC_PATH_E2BIG, 0x42, \
473  LCB_ERRTYPE_INPUT|LCB_ERRTYPE_SRVGEN|LCB_ERRTYPE_SUBDOC, \
474  "Sub-document contains too many components") \
475  X(LCB_SUBDOC_DOC_E2DEEP, 0x43,\
476  LCB_ERRTYPE_DATAOP|LCB_ERRTYPE_SRVGEN|LCB_ERRTYPE_SUBDOC, \
477  "Existing document contains too many levels of nesting") \
478  X(LCB_SUBDOC_VALUE_CANTINSERT, 0x44, \
479  LCB_ERRTYPE_INPUT|LCB_ERRTYPE_SRVGEN|LCB_ERRTYPE_SUBDOC, \
480  "Subdocument operation would invalidate the JSON") \
481  X(LCB_SUBDOC_DOC_NOTJSON, 0x45,\
482  LCB_ERRTYPE_DATAOP|LCB_ERRTYPE_SRVGEN|LCB_ERRTYPE_SUBDOC, \
483  "Existing document is not valid JSON") \
484  X(LCB_SUBDOC_NUM_ERANGE, 0x46, \
485  LCB_ERRTYPE_DATAOP|LCB_ERRTYPE_SRVGEN|LCB_ERRTYPE_SUBDOC, \
486  "The existing numeric value is too large") \
487  X(LCB_SUBDOC_BAD_DELTA, 0x47,\
488  LCB_ERRTYPE_DATAOP|LCB_ERRTYPE_SRVGEN|LCB_ERRTYPE_SUBDOC, \
489  "Delta must be numeric, within the 64 bit signed range, and non-zero") \
490  X(LCB_SUBDOC_PATH_EEXISTS, 0x48,\
491  LCB_ERRTYPE_DATAOP|LCB_ERRTYPE_SRVGEN|LCB_ERRTYPE_SUBDOC, \
492  "The given path already exists in the document") \
493  X(LCB_SUBDOC_MULTI_FAILURE, 0x49,\
494  LCB_ERRTYPE_DATAOP|LCB_ERRTYPE_SRVGEN|LCB_ERRTYPE_SUBDOC, \
495  "Could not execute one or more multi lookups or mutations") \
496  X(LCB_SUBDOC_VALUE_E2DEEP, 0x4A,\
497  LCB_ERRTYPE_INPUT|LCB_ERRTYPE_SRVGEN|LCB_ERRTYPE_SUBDOC, \
498  "Value is too deep to insert") \
499  X(LCB_EINVAL_MCD, 0x4B, LCB_ERRTYPE_SRVGEN|LCB_ERRTYPE_INTERNAL, \
500  "A badly formatted packet was sent to the server. Please report this in a bug") \
501  X(LCB_EMPTY_PATH, 0x4C, LCB_ERRTYPE_INPUT, "Missing subdocument path") \
502  X(LCB_UNKNOWN_SDCMD, 0x4D, LCB_ERRTYPE_INPUT, "Unknown subdocument command") \
503  X(LCB_ENO_COMMANDS, 0x4E, LCB_ERRTYPE_INPUT, "No commands specified")
504 
506 typedef enum {
507  #define X(n, v, cls, s) n = v,
509  #undef X
510 
511  #ifdef LIBCOUCHBASE_INTERNAL
512 
515  LCB_MAX_ERROR_VAL,
516  #endif
517 
518  /* The errors below this value reserver for libcouchbase usage. */
519  LCB_MAX_ERROR = 0x1000
520 } lcb_error_t;
521 
523 #define LCB_EIFINPUT(e) (lcb_get_errtype(e) & LCB_ERRTYPE_INPUT)
524 
526 #define LCB_EIFNET(e) (lcb_get_errtype(e) & LCB_ERRTYPE_NETWORK)
527 
529 #define LCB_EIFFATAL(e) (lcb_get_errtype(e) & LCB_ERRTYPE_FATAL)
530 
532 #define LCB_EIFTMP(e) (lcb_get_errtype(e) & LCB_ERRTYPE_TRANSIENT)
533 
535 #define LCB_EIFDATA(e) (lcb_get_errtype(e) & LCB_ERRTYPE_DATAOP)
536 
538 #define LCB_EIFPLUGIN(e) (lcb_get_errtype(e) & LCB_ERRTYPE_PLUGIN)
539 #define LCB_EIFSRVLOAD(e) (lcb_get_errtype(e) & LCB_ERRTYPE_SRVLOAD)
540 #define LCB_EIFSRVGEN(e) (lcb_get_errtype(e) & LCB_ERRTYPE_SRVGEN)
541 #define LCB_EIFSUBDOC(e) (lcb_get_errtype(e) & LCB_ERRTYPE_SUBDOC)
542 
549 LIBCOUCHBASE_API
551 
561 LIBCOUCHBASE_API
562 const char *lcb_strerror(lcb_t instance, lcb_error_t error);
563 
569 LIBCOUCHBASE_API
570 lcb_error_t lcb_errmap_default(lcb_t instance, lcb_U16 code);
571 
580 typedef lcb_error_t (*lcb_errmap_callback)(lcb_t instance, lcb_U16 bincode);
581 
583 LIBCOUCHBASE_API
585 
586 #ifdef __cplusplus
587 }
588 #endif
589 
590 #endif
const char * lcb_strerror(lcb_t instance, lcb_error_t error)
Get a textual descrtiption for the given error code.
Error code indicates document (fulldoc) access ok, but error in performing subdocument operation...
Definition: error.h:85
lcb_errmap_callback lcb_set_errmap_callback(lcb_t, lcb_errmap_callback)
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
struct lcb_st * lcb_t
Library handle representing a connection to a data bucket.
Definition: couchbase.h:41
lcb_error_t
Error codes returned by the library.
Definition: error.h:506
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:103
lcb_error_t lcb_errmap_default(lcb_t instance, lcb_U16 code)
This may be used in conjunction with the errmap callback if it wishes to fallback for default behavio...
lcb_error_t(* lcb_errmap_callback)(lcb_t instance, lcb_U16 bincode)
Callback for error mappings.
Definition: error.h:579