# HG changeset patch # User Kim Alvefur # Date 1601133394 -7200 # Node ID 0b68697450c580d00f2243e2e296f92761aed5fe # Parent ba77c142c9b1cf8be87f77fa7a91103e6834247c util.error: Add well-known field 'extra' A place for various extra fields and edge cases of the stanza error data model, e.g. the URI field of diff -r ba77c142c9b1 -r 0b68697450c5 spec/util_error_spec.lua --- a/spec/util_error_spec.lua Fri Sep 25 16:39:22 2020 +0100 +++ b/spec/util_error_spec.lua Sat Sep 26 17:16:34 2020 +0200 @@ -66,5 +66,13 @@ end); end); + describe("extra", function () + it("keeps some extra fields", function () + local err = errors.new({condition="gone",text="Sorry mate, it's all gone",extra={uri="file:///dev/null"}}); + assert.is_table(err.extra); + assert.equal("file:///dev/null", err.extra.uri); + end); + end) + end); diff -r ba77c142c9b1 -r 0b68697450c5 util/error.lua --- a/util/error.lua Fri Sep 25 16:39:22 2020 +0100 +++ b/util/error.lua Sat Sep 26 17:16:34 2020 +0200 @@ -43,6 +43,7 @@ type = e.type; condition = e.condition; text = e.text; + extra = e.extra; }; else template = {}; @@ -61,6 +62,7 @@ condition = template.condition or "undefined-condition"; text = template.text; code = template.code; + extra = template.extra; context = context; source = source;