* Geoff Leyland:
function a()
-- could cause an error, could return different numbers of values
return 1, nil, 2
end
function b()
local status, r = pcall(function() return { a() } end)
if not r then error("nicely handled error!") end
return unpack(r)
end
I guess you should use a helper function and a tail call, like this:
function a()
-- could cause an error, could return different numbers of values
return 1, nil, 2
end
do
local function b1(status, r, ...)
if not r then error("nicely handled error!") end -- ??? status?
return r, ...
end
function b()
return b1(pcall(a))
end
end