Skip to content

Commit 6f2260e

Browse files
authored
Preserve error message in OpenOS error handling (#3767)
1 parent 4997b2f commit 6f2260e

File tree

1 file changed

+4
-4
lines changed
  • src/main/resources/assets/opencomputers/loot/openos/lib

1 file changed

+4
-4
lines changed

src/main/resources/assets/opencomputers/loot/openos/lib/process.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ function process.load(path, env, init, name)
6868
if type(msg) == "table" and msg.reason == "terminated" then
6969
return msg.code or 0
7070
end
71-
return debug.traceback()
71+
return {msg, debug.traceback()}
7272
end, ...)
7373
}
7474

75-
if not result[1] and type(result[2]) ~= "number" then
75+
if not result[1] and type(result[2]) == "table" then
7676
-- run exception handler
7777
xpcall(function()
78-
local stack = result[2]:gsub("^([^\n]*\n)[^\n]*\n[^\n]*\n","%1")
79-
io.stderr:write(string.format("%s:\n%s", msg or "", stack))
78+
local stack = result[2][2]:gsub("^([^\n]*\n)[^\n]*\n[^\n]*\n","%1")
79+
io.stderr:write(string.format("%s:\n%s", result[2][1] or "", stack))
8080
end,
8181
function(msg)
8282
io.stderr:write("process library exception handler crashed: ", tostring(msg))

0 commit comments

Comments
 (0)