lua/msgpack: enable encoding errors as msgpack extension
This patch adds a new msgpack.cfg: encode_error_as_ext. Setting it makes msgpack and msgpackffi modules encode errors as the MP_ERROR msgpack extension. If the flag is unset, msgpack.encode behavior depends on encode_load_metatables, encode_use_tostring, and encode_invalid_as_nil options, see luaL_convertfield(), while msgpackffi.encode() will always encode errors as strings. The latter needs to be fixed, but it's out of the scope of this work and tracked separately, see #4499. The new option is enabled by default. Interaction with box.session.settings.error_marshaling_enabled: errors are encoded as the MP_ERROR msgpack extension when returned via IPROTO iff both error_marshaling_enabled and encode_error_as_ext are set. Closes #6433 @TarantoolBot document Title: Document msgpack.cfg.encode_error_as_ext The new option determines how error objects (see box.error.new) are encoded in the msgpack format: - If it's set, errors are encoded as the MP_ERROR msgpack extension. This is the default behavior. - If it's unset, the encoded format depends on other msgpack configuration options (encode_load_metatables, encode_use_tostring, encode_invalid_as_nil). With the otherwise default configuration, they are encoded as strings (see error.message). Functions affected by the default configuration (msgpack.cfg): - msgpack and msgpackffi modules - Storing errors in tuples and spaces (box.tuple.new) - Returning errors from IPROTO CALL/EVAL
Showing
- changelogs/unreleased/gh-6433-msgpack-encode-error-cfg.md 5 additions, 0 deletionschangelogs/unreleased/gh-6433-msgpack-encode-error-cfg.md
- extra/exports 2 additions, 0 deletionsextra/exports
- src/box/mp_error.cc 18 additions, 0 deletionssrc/box/mp_error.cc
- src/box/mp_error.h 17 additions, 0 deletionssrc/box/mp_error.h
- src/lua/msgpack.c 2 additions, 1 deletionsrc/lua/msgpack.c
- src/lua/msgpackffi.lua 14 additions, 0 deletionssrc/lua/msgpackffi.lua
- src/lua/serializer.c 1 addition, 0 deletionssrc/lua/serializer.c
- src/lua/serializer.h 2 additions, 0 deletionssrc/lua/serializer.h
- test/app-tap/lua/serializer_test.lua 30 additions, 0 deletionstest/app-tap/lua/serializer_test.lua
- test/app-tap/msgpack.test.lua 2 additions, 1 deletiontest/app-tap/msgpack.test.lua
- test/app-tap/msgpackffi.test.lua 1 addition, 12 deletionstest/app-tap/msgpackffi.test.lua
- test/box-tap/extended_error.test.lua 11 additions, 1 deletiontest/box-tap/extended_error.test.lua
- test/box/gh-4513-netbox-self-and-connect-interchangeable.result 5 additions, 2 deletions...ox/gh-4513-netbox-self-and-connect-interchangeable.result
- test/box/gh-4513-netbox-self-and-connect-interchangeable.test.lua 2 additions, 1 deletion.../gh-4513-netbox-self-and-connect-interchangeable.test.lua
Loading
Please register or sign in to comment