1 local stanza_mt = getmetatable(require "util.stanza".stanza()); |
|
2 |
|
3 local xmlns_stanzas = "urn:ietf:params:xml:ns:xmpp-stanzas"; |
|
4 |
|
5 function stanza_mt:get_error() |
|
6 local type, condition, text; |
|
7 |
|
8 local error_tag = self:get_child("error"); |
|
9 if not error_tag then |
|
10 return nil, nil; |
|
11 end |
|
12 type = error_tag.attr.type; |
|
13 |
|
14 for child in error_tag:children() do |
|
15 if child.attr.xmlns == xmlns_stanzas then |
|
16 if child.name == "text" then |
|
17 text = child:get_text(); |
|
18 else |
|
19 condition = child.name; |
|
20 end |
|
21 if condition and text then |
|
22 break; |
|
23 end |
|
24 end |
|
25 end |
|
26 return type, condition, text; |
|
27 end |
|