box.error()
-
box.
error
()¶ Raise the last error.
See also: box.error.last()
-
box.
error
(error_object) Raise the error defined by error_object.
Параметры: - error_object (
error_object
) – an error object
Example
local custom_error = box.error.new({ code = 500, reason = 'Internal server error' }) box.error(custom_error) --[[ --- - error: Internal server error ... --]]
- error_object (
-
box.
error
({ reason = string[, code = number, type = string] }]) Raise the error defined by the specified parameters.
Параметры: Example 1
box.error { code = 500, reason = 'Custom server error' } --[[ --- - error: Custom server error ... --]]
Example 2: custom type
box.error { code = 500, reason = 'Internal server error', type = 'CustomInternalError' } --[[ --- - error: Internal server error ... --]]
-
box.
error
(type, reason[, ...]) Raise the error defined by the specified type and description.
Параметры: Example 1: without arguments
box.error('CustomConnectionError', 'cannot connect to the given port') --[[ --- - error: cannot connect to the given port ... --]]
Example 2: with arguments
box.error('CustomConnectionError', '%s cannot connect to the port %u', 'client', 8080) --[[ --- - error: client cannot connect to the port 8080 ... --]]
-
box.
error
(code[, ...]) Raise a predefined Tarantool error specified by its identifier. You can see all Tarantool errors in the errcode.h file.
Параметры: - code (
number
) – a pre-defined error identifier; Lua constants that correspond to those Tarantool errors are defined as members ofbox.error
, for example,box.error.NO_SUCH_USER == 45
- ... – description arguments
Example 1: no arguments
box.error(box.error.READONLY) --[[ --- - error: Can't modify data on a read-only instance ... --]]
Example 2: one argument
box.error(box.error.NO_SUCH_USER, 'John') --[[ --- - error: User 'John' is not found ... --]]
Example 3: two arguments
box.error(box.error.CREATE_SPACE, 'my_space', 'the space already exists') --[[ --- - error: 'Failed to create space ''my_space'': the space already exists' ... --]]
- code (