util.error: Pass converted stanza errors throguh new()
authorKim Alvefur <zash@zash.se>
Sun, 27 Sep 2020 00:17:48 +0200
changeset 11098 03fdf41fd948
parent 11097 ec14d4fce855
child 11099 1ea3574b19c8
util.error: Pass converted stanza errors throguh new() In order to benefit from common processing
util/error.lua
--- a/util/error.lua	Sat Sep 26 23:17:53 2020 +0200
+++ b/util/error.lua	Sun Sep 27 00:17:48 2020 +0200
@@ -91,14 +91,14 @@
 	return ok, new_err, ...;
 end
 
-local function from_stanza(stanza, context)
+local function from_stanza(stanza, context, source)
 	local error_type, condition, text, extra_tag = stanza:get_error();
 	local error_tag = stanza:get_child("error");
 	context = context or {};
 	context.stanza = stanza;
 	context.by = error_tag.attr.by or stanza.attr.from;
 
-	return setmetatable({
+	return new({
 		type = error_type or "cancel";
 		condition = condition or "undefined-condition";
 		text = text;
@@ -106,10 +106,7 @@
 			uri = error_tag:get_child_text("gone", "urn:ietf:params:xml:ns:xmpp-stanzas");
 			tag = extra_tag;
 		} or nil;
-
-		context = context;
-
-	}, error_mt);
+	}, context, nil, source);
 end
 
 return {