diff options
author | Kim Alvefur <zash@zash.se> | 2020-08-28 13:55:05 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2020-08-28 13:55:05 +0200 |
commit | a114e8cf0237266237412c98de3fbb2610e7a31b (patch) | |
tree | dccd01b47f4ecdbc68a864d5d1e0dd4d524a0231 | |
parent | df7cf5c388e5be03dfc5f57229b8f1ee7b355ded (diff) | |
download | prosody-a114e8cf0237266237412c98de3fbb2610e7a31b.tar.gz prosody-a114e8cf0237266237412c98de3fbb2610e7a31b.zip |
util.error: Add a wrapper for common parameters
Lets you set up source and registry once per module
-rw-r--r-- | util/error.lua | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/util/error.lua b/util/error.lua index 600c9e5e..c46f8790 100644 --- a/util/error.lua +++ b/util/error.lua @@ -52,6 +52,12 @@ local function new(e, context, registry, source) }, 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 @@ end return { new = new; + init = init; coerce = coerce; is_err = is_err; from_stanza = from_stanza; |