Software / code / prosody
Comparison
util/error.lua @ 11077:8ea430de5fd3
util.error: Minor tweaks to error creation code to prepare for future changes
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Fri, 25 Sep 2020 12:27:45 +0100 |
| parent | 11076:505c3e5907a5 |
| child | 11078:fb3aec3dbe21 |
comparison
equal
deleted
inserted
replaced
| 11076:505c3e5907a5 | 11077:8ea430de5fd3 |
|---|---|
| 40 | 40 |
| 41 if auto_inject_traceback then | 41 if auto_inject_traceback then |
| 42 context.traceback = debug.traceback("error stack", 2); | 42 context.traceback = debug.traceback("error stack", 2); |
| 43 end | 43 end |
| 44 | 44 |
| 45 return setmetatable({ | 45 local error_instance = setmetatable({ |
| 46 instance_id = id.short(); | 46 instance_id = id.short(); |
| 47 | |
| 47 type = template.type or "cancel"; | 48 type = template.type or "cancel"; |
| 48 condition = template.condition or "undefined-condition"; | 49 condition = template.condition or "undefined-condition"; |
| 49 text = template.text; | 50 text = template.text; |
| 50 code = template.code; | 51 code = template.code; |
| 51 | 52 |
| 52 context = context or template.context or { _error_id = e }; | 53 context = context; |
| 53 source = source; | 54 source = source; |
| 54 }, error_mt); | 55 }, error_mt); |
| 56 | |
| 57 return error_instance; | |
| 55 end | 58 end |
| 56 | 59 |
| 57 local function init(source, registry) | 60 local function init(source, registry) |
| 58 return function (e, context) | 61 return function (e, context) |
| 59 return new(e, context, registry, source); | 62 return new(e, context, registry, source); |