Error Code Checking As previously discussed, the Couchbase .NET Client has two forms of CRUD methods: those that return the primitive value (e.g. bool, integer, etc) of the result and those that return an IOperationResult object. The former methods have a signature that matches the operation’s name (e.g. Increment(..)) and the latter methods have a signature with a prefix of the “Execute” (e.g. ExecuteIncrement). The benefit of using the IOperationResult methods is that they give you additional information of about the result of the operation which allows you to handle specific error or failure cases or to determine what caused the error to occur. Of major importance is the Success, StatusCode, Message and Exception fields. A description of each field: Success – returns Boolean true if operation was successful, otherwise false StatusCode – returns an integer value indicating the response status from the server or the IO portion of the client. There is also an enumeration describing the values and extension method that makes the conversion simple. Message – a string describing the error that occurred Exception – the exception caused by the error Status Codes Perhaps the most important field is the StatusCode field. Here is a table with the numerical value, enum value and description of each StatusCode: Enum value Success KeyNotFound KeyExists ValueToLarge InvalidArguments ItemNotStored IncrDecrOnNonNumericValue Numerical 0 1 2 3 4 5 6 Origin Server Server Server Server Server Server Server VBucketBelongsToAnotherServer 7 Server AuthenticationError 20 Server AuthenticationContinue InvalidRange UnknownCommand 21 22 81 Server Server Server Description Operation was successful Key was not found on server Key already exists on server Value is to large The operations arguments are invalid The item could not be stored. An attempt was made to increment or decrement a non-numeric value – e.g. a string The VBucket the key is mapped too has been changed. Common during rebalance scenarios and operation should be retried. SASL authentication has failed. Check the password or username of the server or bucket. Used during SASL authentication. Invalid range was specified Operation was not recognized by server. Should never occur with a Couchbase supported client. OutOfMemory 82 Server NotSupported 83 Server InternalError Busy 84 85 Server Server TemporaryFailure SocketPoolTimeout 86 91 Server Client UnableToLocateNode 92 Client NodeShutdown 93 Client OperationTimeout 94 Client Server is out of memory. This is usually temporary, but should prompt further investigation A client attempted an operation that was not supported by the server. Server error state. Server is temporarily too busy. This may warrant a retry attempt. A timeout has occurred while attempting to retrieve a connection. This can happen during rebalance scenarios or during times of high throughput on the client. A retry attempt is warranted in this case. Usually a temporary state of the client during rebalance/failover scenarios when a configuration change has occurred (server added or removed from cluster for example). A retry attempt is warranted in this case. Temporary client state during a configuration change when an operation is using the older state of the cluster. A retry attempt is warranted in this case. The 1.X client uses synchronous IO, If a connection is terminated by the server a timeout will occur after n seconds on the client if the current operation does not complete. A retry attempt is warranted in this case. Note the StatusCode enumeration is found within Enyim.Caching assembly: Enyim.Caching.StatusCode.