Comparison

util/error.lua @ 11092:bd13aa89262d

util.error: Collect Application-Specific Conditions from stanza errors
author Kim Alvefur <zash@zash.se>
date Sat, 26 Sep 2020 18:15:49 +0200
parent 11091:4b4b5188492f
child 11094:03fdf41fd948
comparison
equal deleted inserted replaced
11091:4b4b5188492f 11092:bd13aa89262d
90 90
91 return ok, new_err, ...; 91 return ok, new_err, ...;
92 end 92 end
93 93
94 local function from_stanza(stanza, context) 94 local function from_stanza(stanza, context)
95 local error_type, condition, text = stanza:get_error(); 95 local error_type, condition, text, extra_tag = stanza:get_error();
96 local error_tag = stanza:get_child("error"); 96 local error_tag = stanza:get_child("error");
97 context = context or {}; 97 context = context or {};
98 context.stanza = stanza; 98 context.stanza = stanza;
99 context.by = error_tag.attr.by or stanza.attr.from; 99 context.by = error_tag.attr.by or stanza.attr.from;
100 100
101 return setmetatable({ 101 return setmetatable({
102 type = error_type or "cancel"; 102 type = error_type or "cancel";
103 condition = condition or "undefined-condition"; 103 condition = condition or "undefined-condition";
104 text = text; 104 text = text;
105 extra = condition == "gone" and { 105 extra = (extra_tag or condition == "gone") and {
106 uri = error_tag:get_child_text("gone", "urn:ietf:params:xml:ns:xmpp-stanzas"); 106 uri = error_tag:get_child_text("gone", "urn:ietf:params:xml:ns:xmpp-stanzas");
107 tag = extra_tag;
107 } or nil; 108 } or nil;
108 109
109 context = context; 110 context = context;
110 111
111 }, error_mt); 112 }, error_mt);