| Tarantool
Документация на русском языке
поддерживается сообществом, errtext[, errtext ...])

Create an error object, but not throw it as box.error() does. This is useful when error information should be saved for later retrieval. Since version 2.4.1, to set an error as the last explicitly use box.error.set().

  • code (number) – номер предварительно заданной ошибки
  • errtext(s) (string) – часть сообщения, которое сопровождает ошибку


tarantool> e:unpack()
- code: 5
  base_type: CustomError
  type: B
  custom_type: B
  message: A
  - file: '[string "{code=5,reason=''A'',type=''B''}"]'
    line: 1
tarantool> box.error.last()
- null

Since version 2.4.1, the error_marshaling_enabled setting has been introduced in _session_settings. The new setting affects the structure of error objects. If error_marshaling_enabled is set to true, the object will have the MP_EXT type and the MP_ERROR subtype.

Using the binary protocol, the server can send a packet in response to The body of that packet contains the following data:

  • the encoding of MP_EXT according to the MessagePack specification (usually 0xc7)
  • the encoding of MP_ERROR (0x03)
  • the encoding of MP_ERROR_STACK (0x81)
  • all of the MP_ERROR_STACK components: an MP_ARRAY containing an MP_MAP which, in turn, contains keys like MP_ERROR_MESSAGE, MP_ERROR_CODE, etc. These components are described and illustrated in the section MessagePack extensions – The ERROR type.

The error object map fields correspond to specific keys:

  • «type» corresponds to MP_ERROR_TYPE
  • «code» corresponds to MP_ERROR_ERRCODE
  • «message» corresponds to MP_ERROR_MESSAGE.
Нашли ответ на свой вопрос?
Обратная связь