util.error: Add a wrapper for common parameters
Lets you set up source and registry once per module
--- 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;