Skip to content

Commit a63f083

Browse files
net.box: make handle_eval_result more robust
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>
1 parent 89e3760 commit a63f083

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/box/lua/net_box.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1365,7 +1365,13 @@ end
13651365
local function handle_eval_result(status, ...)
13661366
if not status then
13671367
rollback()
1368-
return box.error(E_PROC_LUA, (...))
1368+
local err = ...
1369+
if type(err) == 'string' then
1370+
box.error(E_PROC_LUA, err)
1371+
end
1372+
err = err:unpack()
1373+
err.code = E_PROC_LUA
1374+
return box.error(err)
13691375
end
13701376
local results = {...}
13711377
for i = 1, select('#', ...) do

0 commit comments

Comments
 (0)