Mercurial > prosody-hg
comparison util/error.lua @ 11080:ba77c142c9b1
util.error: Simplify error creation flow
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Fri, 25 Sep 2020 16:39:22 +0100 |
| parents | 1e5a0e0469de |
| children | 0b68697450c5 |
comparison
equal
deleted
inserted
replaced
| 11079:1e5a0e0469de | 11080:ba77c142c9b1 |
|---|---|
| 33 -- Translations? | 33 -- Translations? |
| 34 -- Should the `type` be restricted to the stanza error types or free-form? | 34 -- Should the `type` be restricted to the stanza error types or free-form? |
| 35 -- What to set `type` to for stream errors or SASL errors? Those don't have a 'type' attr. | 35 -- What to set `type` to for stream errors or SASL errors? Those don't have a 'type' attr. |
| 36 | 36 |
| 37 local function new(e, context, registry, source) | 37 local function new(e, context, registry, source) |
| 38 local template = (registry and registry[e]) or e or {}; | 38 local template = registry and registry[e]; |
| 39 if not template then | |
| 40 if type(e) == "table" then | |
| 41 template = { | |
| 42 code = e.code; | |
| 43 type = e.type; | |
| 44 condition = e.condition; | |
| 45 text = e.text; | |
| 46 }; | |
| 47 else | |
| 48 template = {}; | |
| 49 end | |
| 50 end | |
| 39 context = context or {}; | 51 context = context or {}; |
| 40 | 52 |
| 41 if auto_inject_traceback then | 53 if auto_inject_traceback then |
| 42 context.traceback = debug.traceback("error stack", 2); | 54 context.traceback = debug.traceback("error stack", 2); |
| 43 end | 55 end |
