# HG changeset patch # User Kim Alvefur # Date 1598615705 -7200 # Node ID ad07152d7bde2856dbb89d514172ded4295a7080 # Parent 04ad9555c799b0f769f06759f4058c6bb8b979f1 util.error: Add a wrapper for common parameters Lets you set up source and registry once per module diff -r 04ad9555c799 -r ad07152d7bde util/error.lua --- 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;