diff options
author | Matthew Wild <mwild1@gmail.com> | 2020-09-25 16:39:22 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2020-09-25 16:39:22 +0100 |
commit | 3e3ce993e6b3573f96ebbadae405ba753c4a5c8f (patch) | |
tree | b21945cf5c6638fe9b1b679825ab0c65e61b7c56 /util/error.lua | |
parent | bcd629fbc17aab71e0ab7ce04a931626ff5b9df0 (diff) | |
download | prosody-3e3ce993e6b3573f96ebbadae405ba753c4a5c8f.tar.gz prosody-3e3ce993e6b3573f96ebbadae405ba753c4a5c8f.zip |
util.error: Simplify error creation flow
Diffstat (limited to 'util/error.lua')
-rw-r--r-- | util/error.lua | 14 |
1 files changed, 13 insertions, 1 deletions
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 |