box.error.new()
-
box.error.
new
({ reason = string[, code = number, type = string] }])¶ Create an error object with the specified parameters.
Параметры: Example 1
local custom_error = box.error.new({ code = 500, reason = 'Internal server error' }) box.error(custom_error) --[[ --- - error: Internal server error ... --]]
Example 2: custom type
local custom_error = box.error.new({ code = 500, reason = 'Internal server error', type = 'CustomInternalError' }) box.error(custom_error) --[[ --- - error: Internal server error ... --]]
-
box.error.
new
(type, reason[, ...]) Create an error object with the specified type and description.
Параметры: Example
local custom_error = box.error.new('CustomInternalError', 'Internal server error') box.error(custom_error) --[[ --- - error: Internal server error ... --]]
-
box.error.
new
(code[, ...]) Create 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: one argument
local custom_error = box.error.new(box.error.NO_SUCH_USER, 'John') box.error(custom_error) --[[ --- - error: User 'John' is not found ... --]]
Example 2: two arguments
local custom_error = box.error.new(box.error.CREATE_SPACE, 'my_space', 'the space already exists') box.error(custom_error) --[[ --- - error: 'Failed to create space ''my_space'': the space already exists' ... --]]
- code (