commit 528c7a957d54f6687e522ec5592876e16063c273
parent 50f019c2d54bea230fb84cc097dc31a4aa5a4055
Author: phoebos <ben@bvnf.space>
Date: Fri, 28 Jul 2023 12:34:15 +0100
run action under pcall; no traceback on die
Diffstat:
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/bliss/utils.lua b/bliss/utils.lua
@@ -187,7 +187,6 @@ end
function die(name, msg)
log(name, msg, "ERROR")
- print(debug.traceback(nil, 2))
os.exit(false)
end
diff --git a/main.lua b/main.lua
@@ -78,7 +78,18 @@ local function args(env, arg)
local f = args_map[char]
if f then
- f(env, arg)
+ -- Run in protected mode. This is to catch bugs rather than user-facing
+ -- error handling. None of the action functions return a value; we're
+ -- only interested in if they fail or succeed.
+ if not xpcall(f, function (msg)
+ print(msg)
+ print(debug.traceback())
+ end, env, arg)
+ then
+ bliss.log("An exception was caught, not removing temporary files")
+ bliss.trap_off(env)
+ os.exit(1)
+ end
else
-- TODO: ext
usage()