util/error.lua
changeset 11084 ba77c142c9b1
parent 11083 1e5a0e0469de
child 11085 0b68697450c5
--- a/util/error.lua	Fri Sep 25 12:38:58 2020 +0100
+++ b/util/error.lua	Fri Sep 25 16:39:22 2020 +0100
@@ -35,7 +35,19 @@
 -- What to set `type` to for stream errors or SASL errors? Those don't have a 'type' attr.
 
 local function new(e, context, registry, source)
-	local template = (registry and registry[e]) or e or {};
+	local template = registry and registry[e];
+	if not template then
+		if type(e) == "table" then
+			template = {
+				code = e.code;
+				type = e.type;
+				condition = e.condition;
+				text = e.text;
+			};
+		else
+			template = {};
+		end
+	end
 	context = context or {};
 
 	if auto_inject_traceback then