WiredTiger operations return a value of 0 on success and a non-zero value on error. Error codes may be either positive or negative: positive error codes are standard error codes as described for POSIX-like systems (for example, EINVAL
or EBUSY
), negative error codes are WiredTiger-specific (for example, WT_ROLLBACK
).
WiredTiger-specific error codes always appear in the -31,800 to -31,999 range, inclusive.
Informational return values, like wiredtiger.WT_NOTFOUND
or wiredtiger.WT_DUPLICATE_KEY
or 0 (success), are directly returned by APIs. More severe errors are thrown as WiredTigerException
, which may be caught by the application.
The WiredTigerRollbackException
is a specific type of WiredTigerException
, thrown when there is a conflict between concurrent operations. An application that catches this exception should call rollback() on the relevant transaction, and retry as necessary.
The WiredTigerPanicException
is a specific type of WiredTigerException
, thrown when there is a fatal error requiring database restart. Applications will normally handle WiredTigerPanicException
as a special case. A correctly-written WiredTiger application will likely catch WiredTigerPanicException
and immediately exit or otherwise handle fatal errors. Note that no further WiredTiger calls are required after WiredTigerPanicException
is caught (and further calls will themselves immediately fail).
WiredTiger returns EBUSY
for operations requiring exclusive access, when an object is not available for exclusive access. For example, the Session.drop or Session.verify methods will fail if the object has open cursors. Note that internal WiredTiger threads may temporarily open cursors on objects (for example, threads performing operations like statistics logging), and operations may temporarily fail and return EBUSY
when there are no application cursors open on the object.
The following is a complete list of the WiredTiger-specific return values, all constants defined in the com.wiredtiger.db.wiredtiger class:
The Session.strerror and wiredtiger_strerror functions return the standard text message associated with any WiredTiger, ISO C, or POSIX standard API.
Note that wiredtiger_strerror is not thread-safe.