aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2020-08-28 13:55:05 +0200
committerKim Alvefur <zash@zash.se>2020-08-28 13:55:05 +0200
commita114e8cf0237266237412c98de3fbb2610e7a31b (patch)
treedccd01b47f4ecdbc68a864d5d1e0dd4d524a0231
parentdf7cf5c388e5be03dfc5f57229b8f1ee7b355ded (diff)
downloadprosody-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.lua7
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;