util.error: Add well-known field 'code' in error templates

Intended to be for HTTP-ish numeric status codes
This commit is contained in:
Kim Alvefur 2019-11-01 18:31:12 +01:00
parent 9f13e20ffe
commit 03adb50555
2 changed files with 3 additions and 0 deletions

View file

@ -16,11 +16,13 @@ describe("util.error", function ()
["fail"] = {
type = "wait",
condition = "internal-server-error",
code = 555;
};
};
local err = errors.new("fail", { traceback = "in some file, somewhere" }, templates);
assert.equal("wait", err.type);
assert.equal("internal-server-error", err.condition);
assert.equal(555, err.code);
assert.same({ traceback = "in some file, somewhere" }, err.context);
end);
end);