feat(sandbox) return multiple values

This commit is contained in:
eskerda
2020-12-13 18:54:40 +01:00
committed by Enrique García Cota
parent 8974b8869c
commit 9f83b8914a
2 changed files with 9 additions and 3 deletions

View File

@@ -166,12 +166,13 @@ function sandbox.protect(f, options)
string.rep = nil
local ok, result = pcall(f, ...)
local t = table.pack(pcall(f, ...))
cleanup()
if not ok then error(result) end
return result
if not t[1] then error(t[2]) end
return table.unpack(t, 2, t.n)
end
end