From a34633771db29e751058f93b1abbfd6801283364 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 25 Sep 2020 16:39:22 +0100 Subject: util.error: Simplify error creation flow --- util/error.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'util') diff --git a/util/error.lua b/util/error.lua index 976bc355..cfb35350 100644 --- a/util/error.lua +++ b/util/error.lua @@ -35,7 +35,19 @@ end -- What to set `type` to for stream errors or SASL errors? Those don't have a 'type' attr. local function new(e, context, registry, source) - local template = (registry and registry[e]) or e or {}; + local template = registry and registry[e]; + if not template then + if type(e) == "table" then + template = { + code = e.code; + type = e.type; + condition = e.condition; + text = e.text; + }; + else + template = {}; + end + end context = context or {}; if auto_inject_traceback then -- cgit v1.2.3