mirror of
https://github.com/TangentFoxy/lua-sandbox.git
synced 2025-07-28 02:52:22 +00:00
feat(sandbox) return multiple values
This commit is contained in:
committed by
Enrique García Cota
parent
8974b8869c
commit
9f83b8914a
@@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user