# HG changeset patch # User Kim Alvefur # Date 1601329682 -7200 # Node ID 5a0ff475ecfd1cc9b77c5b93b3d963ac67830cd3 # Parent 2288d206b14b9efc2871dd03569a14b5b42d2e30 util.error: Drop registry initialization with namespace as key Enough complexity with compact vs normal and with/without namespace diff -r 2288d206b14b -r 5a0ff475ecfd spec/util_error_spec.lua --- a/spec/util_error_spec.lua Mon Sep 28 22:13:04 2020 +0200 +++ b/spec/util_error_spec.lua Mon Sep 28 23:48:02 2020 +0200 @@ -96,8 +96,7 @@ end); it("compact mode works", function() - local reg = errors.init("test", { - namespace = "spec"; + local reg = errors.init("test", "spec", { broke = {"cancel"; "internal-server-error"; "It broke :("}; nope = {"auth"; "not-authorized"; "Can't let you do that Dave"; "sorry-dave"}; }); @@ -126,26 +125,20 @@ extra = {namespace = "spec"; condition = "sorry-dave"}; }; }); - local compact1 = errors.init("test", { - namespace = "spec"; + local compact1 = errors.init("test", "spec", { broke = {"cancel"; "internal-server-error"; "It broke :("}; nope = {"auth"; "not-authorized"; "Can't let you do that Dave"; "sorry-dave"}; }); - local compact2 = errors.init("test", "spec", { - broke = {"cancel"; "internal-server-error"; "It broke :("}; - nope = {"auth"; "not-authorized"; "Can't let you do that Dave"; "sorry-dave"}; - }); - local compact3 = errors.init("test", { + local compact2 = errors.init("test", { broke = {"cancel"; "internal-server-error"; "It broke :("}; nope = {"auth"; "not-authorized"; "Can't let you do that Dave"}; }); assert.same(normal.registry, compact1.registry); - assert.same(normal.registry, compact2.registry); assert.same({ broke = {type = "cancel"; condition = "internal-server-error"; text = "It broke :("}; nope = {type = "auth"; condition = "not-authorized"; text = "Can't let you do that Dave"}; - }, compact3.registry); + }, compact2.registry); end); end); diff -r 2288d206b14b -r 5a0ff475ecfd util/error.lua --- a/util/error.lua Mon Sep 28 22:13:04 2020 +0200 +++ b/util/error.lua Mon Sep 28 23:48:02 2020 +0200 @@ -92,10 +92,6 @@ if type(namespace) == "table" then -- registry can be given as second argument if namespace is either not used registry, namespace = namespace, nil; - if type(registry.namespace) == "string" then - -- error templates are always type table, so this can't be one - namespace, registry.namespace = registry.namespace, nil; - end end local _, protoerr = next(registry, nil); if protoerr and type(next(protoerr)) == "number" then