fix: returning all the values for 'mod:pcall' and 'mod:dofile' calls
This commit is contained in:
parent
13ac23b971
commit
1bf9822098
1 changed files with 12 additions and 7 deletions
|
@ -19,6 +19,11 @@ local function safe_format(mod, str, ...)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function pack_pcall(status, ...)
|
||||||
|
|
||||||
|
return status, {...}
|
||||||
|
end
|
||||||
|
|
||||||
local function send_to_chat(message)
|
local function send_to_chat(message)
|
||||||
|
|
||||||
if Managers.chat and Managers.chat:has_channel(1) then
|
if Managers.chat and Managers.chat:has_channel(1) then
|
||||||
|
@ -138,27 +143,27 @@ end
|
||||||
|
|
||||||
|
|
||||||
VMFMod.pcall = function (self, ...)
|
VMFMod.pcall = function (self, ...)
|
||||||
local status, value = pcall(...)
|
local status, values = pack_pcall(pcall(...))
|
||||||
|
|
||||||
if not status then
|
if not status then
|
||||||
self:error("(pcall): %s", tostring(value))
|
self:error("(pcall): %s", tostring(values[1]))
|
||||||
end
|
end
|
||||||
|
|
||||||
return status, value
|
return status, unpack(values)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
VMFMod.dofile = function (self, script_path)
|
VMFMod.dofile = function (self, script_path)
|
||||||
|
|
||||||
local success, value = pcall(dofile, script_path)
|
local success, values = pack_pcall(pcall(dofile, script_path))
|
||||||
|
|
||||||
if not success then
|
if not success then
|
||||||
self:error("(loadfile): %s", value.error)
|
self:error("(loadfile): %s", values[1].error)
|
||||||
|
|
||||||
print("\nTRACEBACK:\n\n" .. tostring(value.traceback) .. "\nLOCALS:\n\n" .. tostring(value.locals))
|
print("\nTRACEBACK:\n\n" .. tostring(values[1].traceback) .. "\nLOCALS:\n\n" .. tostring(values[1].locals))
|
||||||
end
|
end
|
||||||
|
|
||||||
return value
|
return unpack(values)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- ####################################################################################################################
|
-- ####################################################################################################################
|
||||||
|
|
Loading…
Add table
Reference in a new issue