Software /
code /
prosody
Diff
util/error.lua @ 11054:ad07152d7bde
util.error: Add a wrapper for common parameters
Lets you set up source and registry once per module
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 28 Aug 2020 13:55:05 +0200 |
parent | 11053:04ad9555c799 |
child | 11075:d8fad2b48b05 |
line wrap: on
line diff
--- a/util/error.lua Fri Aug 28 13:54:16 2020 +0200 +++ b/util/error.lua Fri Aug 28 13:55:05 2020 +0200 @@ -52,6 +52,12 @@ }, error_mt); end +local function init(source, registry) + return function (e, context) + return new(e, context, registry, source); + end +end + local function coerce(ok, err, ...) if ok or is_err(err) then return ok, err, ...; @@ -79,6 +85,7 @@ return { new = new; + init = init; coerce = coerce; is_err = is_err; from_stanza = from_stanza;