1.27. Database error codes¶
In the current version of the binary protocol, error messages, which are normally more descriptive than error codes, are not present in server responses. The actual message may contain a file name, a detailed reason or operating system error code. All such messages, however, are logged in the error log. Below are general descriptions of some popular codes. A complete list of errors can be found in file errcode.h in the source tree.
List of error codes
|ER_NONMASTER||Can’t modify data on a replication slave.|
|ER_ILLEGAL_PARAMS||Illegal parameters. Malformed protocol message.|
|ER_MEMORY_ISSUE||Out of memory: slab_alloc_arena limit has been reached.|
|ER_WAL_IO||Failed to write to disk. May mean: failed to record a change in the write-ahead log. Some sort of disk error.|
|ER_KEY_PART_COUNT||Key part count is not the same as index part count|
|ER_NO_SUCH_SPACE||The specified space does not exist.|
|ER_NO_SUCH_INDEX||The specified index in the specified space does not exist.|
|ER_PROC_LUA||An error occurred inside a Lua procedure.|
|ER_FIBER_STACK||The recursion limit was reached when creating a new fiber. This usually indicates that a stored procedure is recursively invoking itself too often.|
|ER_UPDATE_FIELD||An error occurred during update of a field.|
|ER_TUPLE_FOUND||A duplicate key exists in a unique index.|
1.28. Handling errors¶
Here are some procedures that can make Lua functions more robust when there are errors, particularly database errors.
Invoke with pcall.Take advantage of Lua’s mechanisms for “Error handling and exceptions”, particularly
pcall. That is, instead of simply invoking with
if pcall(box.space.space-name.function-name, box.space.space-name) ...For some Tarantool box functions, pcall also returns error details including a file-name and line-number within Tarantool’s source code. This can be seen by unpacking. For example:
x, y = pcall(function() box.schema.space.create('') end)
See the tutorial Sum a JSON field for all tuples to see how pcall can fit in an application.
Examine and raise with box.error.
To make a new error and pass it on, the box.error module provides box.error(code, errtext [, errtext ...]).
Put messages in a log using the log module.
And filter messages that are automatically generated, with the logger configuration parameter.