# HG changeset patch # User Matthew Wild # Date 1601048362 -3600 # Node ID ba77c142c9b1cf8be87f77fa7a91103e6834247c # Parent 1e5a0e0469de123cf71f00587fc2fe36f4129e52 util.error: Simplify error creation flow diff -r 1e5a0e0469de -r ba77c142c9b1 util/error.lua --- a/util/error.lua Fri Sep 25 12:38:58 2020 +0100 +++ b/util/error.lua Fri Sep 25 16:39:22 2020 +0100 @@ -35,7 +35,19 @@ -- 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