Skip to content
Snippets Groups Projects
Commit 0c50bf69 authored by Roman Tsisyk's avatar Roman Tsisyk
Browse files

Support for multireturn in wrapped pcall()

parent d7661256
No related branches found
No related tags found
No related merge requests found
......@@ -9,10 +9,13 @@ tarantool_error_message(void);
]]
local pcall_lua = pcall
pcall = function(fun, ...)
local status, msg = pcall_lua(fun, ...)
if status == false and msg == 'C++ exception' then
local function pcall_wrap(status, ...)
if status == false and ... == 'C++ exception' then
return false, ffi.string(ffi.C.tarantool_error_message())
end
return status, msg
return status, ...
end
pcall = function(fun, ...)
return pcall_wrap(pcall_lua(fun, ...))
end
......@@ -5,3 +5,5 @@
pcall inside xpcall: true pcall is ok
pcall with Lua error(): false some message
pcall with box.raise(): false some message
pcall with no return: 1
pcall with multireturn: true 1 2 3
......@@ -28,3 +28,6 @@ local status, msg = pcall(function()
box.raise(box.error.ER_ILLEGAL_PARAMS, 'some message')
end)
print('pcall with box.raise():', status, msg)
print('pcall with no return:', select('#', pcall(function() end)))
print('pcall with multireturn:', pcall(function() return 1, 2, 3 end))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment