Top.Mail.Ru | 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, there is a session_settings setting which affects the structure of error objects. If error_marshaling_enabled is changed to true, then the object will have the MP_EXT type and the MP_ERROR subtype. Using the binary protocol, in the body of a packet that the server could send in response to, one will see: the encoding of MP_EXT according to the MessagePack specification (usually 0xc7), followed by the encoding of MP_ERROR (0x03), followed by the encoding of MP_ERROR_STACK (0x81), followed by all of the MP_ERROR_STACK components (MP_ARRAY which contains MP_MAP which contains keys MP_ERROR_MESSAGE, MP_ERROR_CODE, etc.) that are described and illustrated in section MessagePack extensions – The ERROR type. The map field for error object «type» will have key = MP_ERROR_TYPE, the map field for error object «code» will have key = MP_ERROR_CODE, the map field for error object «message» will have key = MP_ERROR_MESSAGE.