aboutsummaryrefslogtreecommitdiffstats
path: root/util/error.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2020-12-09 14:51:40 +0000
committerMatthew Wild <mwild1@gmail.com>2020-12-09 14:51:40 +0000
commitda31a108578f73d7442989c80f66cfea6bf29ec0 (patch)
tree22857ec63016db2861250f0cbdec8909c3cd7e61 /util/error.lua
parent54d7877a072604830fae5a6d21d7fb592a18f44d (diff)
downloadprosody-da31a108578f73d7442989c80f66cfea6bf29ec0.tar.gz
prosody-da31a108578f73d7442989c80f66cfea6bf29ec0.zip
util.error: Switch to util.debug traceback tables and remove display_tracebacks option
Diffstat (limited to 'util/error.lua')
-rw-r--r--util/error.lua15
1 files changed, 6 insertions, 9 deletions
diff --git a/util/error.lua b/util/error.lua
index e64dfbc5..326c01f8 100644
--- a/util/error.lua
+++ b/util/error.lua
@@ -1,16 +1,13 @@
local id = require "util.id";
+local util_debug; -- only imported on-demand
+
-- Library configuration (see configure())
local auto_inject_traceback = false;
-local display_tracebacks = false;
-
local error_mt = { __name = "error" };
function error_mt:__tostring()
- if display_tracebacks and self.context.traceback then
- return ("error<%s:%s:%s:%s>"):format(self.type, self.condition, self.text or "", self.context.traceback);
- end
return ("error<%s:%s:%s>"):format(self.type, self.condition, self.text or "");
end
@@ -19,11 +16,11 @@ local function is_error(e)
end
local function configure(opt)
- if opt.display_tracebacks ~= nil then
- display_tracebacks = opt.display_tracebacks;
- end
if opt.auto_inject_traceback ~= nil then
auto_inject_traceback = opt.auto_inject_traceback;
+ if auto_inject_traceback then
+ util_debug = require "util.debug";
+ end
end
end
@@ -53,7 +50,7 @@ local function new(e, context, registry, source)
context = context or {};
if auto_inject_traceback then
- context.traceback = debug.traceback("error stack", 2);
+ context.traceback = util_debug.get_traceback_table(nil, 2);
end
local error_instance = setmetatable({