Comparison

libs/xstanza.lua @ 15:be4154ed4e3a

util.xstanza: Fix and rename error_from_stanza() -> get_error()
author Matthew Wild <mwild1@gmail.com>
date Mon, 30 Nov 2009 15:52:52 +0000
parent 6:f8e0ab90d84e
comparison
equal deleted inserted replaced
14:53246b2b933b 15:be4154ed4e3a
1 local stanza_mt = getmetatable(require "util.stanza".stanza()); 1 local stanza_mt = getmetatable(require "util.stanza".stanza());
2 2
3 function stanza_mt:error_from_stanza() 3 local xmlns_stanzas = "urn:ietf:params:xml:ns:xmpp-stanzas";
4
5 function stanza_mt:get_error()
4 local type, condition, text; 6 local type, condition, text;
5 7
6 local error_tag = self:get_child("error", "urn:ietf:params:xml:ns:xmpp-stanzas"); 8 local error_tag = self:get_child("error");
7 if not error_tag then 9 if not error_tag then
8 return nil, nil; 10 return nil, nil;
9 end 11 end
10 type = error.attr.type; 12 type = error_tag.attr.type;
11 13
12 for child in error_tag:children() do 14 for child in error_tag:children() do
13 if child.attr.xmlns == xmlns_stanzas then 15 if child.attr.xmlns == xmlns_stanzas then
14 if child.name == "text" then 16 if child.name == "text" then
15 text = child:get_text(); 17 text = child:get_text();