Skip to content
Snippets Groups Projects
Commit c84a8533 authored by Leonid Vasiliev's avatar Leonid Vasiliev Committed by Kirill Yukhin
Browse files

error: add format string usage to compose a CustomError message

For the CustomError the ability to create a message
using a format string was added.

Closes #4903

@TarantoolBot document
Title: Add format string usage to compose a CustomError message
When an error created using the separate members mode
(box.error(code, errtext[, errtext ...])) in the case of
ClientError error creation, a pre-defined format is used
(corresponding to the error code) (nothing has changed), in
the case of CustomError error creation, a format string can
be used to compose a message.

ClientError(nothing has changed):
```Lua
box.error(code, reason args)
```

Example for ER_CREATE_SPACE:
```Lua
box.error(9, "my_space", "reason")
```
Result:
```Lua
error: 'Failed to create space ''my_space'': reason'
```

CustomError:
```Lua
box.error(type, reason format string, reason args)
```

Example:
```Lua
box.error("MyCustomType", "The error reason: %s", "some error reason")
```
Result:
```Lua
error: 'The error reason: some error reason'
```
parent 366b2de7
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment