Skip to content

Commit

Permalink
net.box: make handle_eval_result more robust
Browse files Browse the repository at this point in the history
Currently, in the error case, `handle_eval_result` constructs a new error
passing the error it receives as an argument (which can be a string or a
box.error) to the message argument of the `box.error` constructor.

Then, during `box.error` construction, if the error argument of
`handle_eval_result` was a `box.error`, it is converted to a string using
the `__tostring` metamethod, which currently returns the error's message,
losing the rest of the error's information.

But in scope of tarantool#9105, we are going to increase the verbosity of the
`__tostring` metamethod, and it will not return the error's message. To
adjust to this new behaviour, let's make `handle_eval_result` more robust,
and either create a simple `ER_PROC_LUA` error if the error is a string, or
change the error object's code to `ER_PROC_LUA` (for
backwards-compatibility) in case the error is a `box.error`.

Needed for tarantool#9105

NO_CHANGELOG=<internal change>
NO_TEST=<internal change>
NO_DOC=<internal change>
  • Loading branch information
CuriousGeorgiy committed Feb 22, 2024
1 parent 2c4c83a commit e6f8a5f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/box/lua/net_box.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,13 @@ end
local function handle_eval_result(status, ...)
if not status then
rollback()
return box.error(E_PROC_LUA, (...))
local err = ...
if type(err) == 'string' then
box.error(E_PROC_LUA, err)
end
err = err:unpack()
err.code = E_PROC_LUA
return box.error(err)
end
local results = {...}
for i = 1, select('#', ...) do
Expand Down

0 comments on commit e6f8a5f

Please sign in to comment.