Changeset

364:69fc23b44819

client: Deal with eg no-stream errors where no stanza is passed
author Kim Alvefur <zash@zash.se>
date Tue, 30 Sep 2014 12:18:28 +0200
parents 363:056ccefa6acf
children 365:48bf6993b4c4
files client.lua
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/client.lua	Tue Sep 30 12:16:33 2014 +0200
+++ b/client.lua	Tue Sep 30 12:18:28 2014 +0200
@@ -53,9 +53,13 @@
 
 function stream_callbacks.error(stream, e, stanza)
 	if stream:event(e, stanza) == nil then
-		local err = stanza:get_child(nil, "urn:ietf:params:xml:ns:xmpp-streams");
-		local text = stanza:get_child_text("text", "urn:ietf:params:xml:ns:xmpp-streams");
-		error(err.name..(text and ": "..text or ""));
+		if stanza then
+			local err = stanza:get_child(nil, "urn:ietf:params:xml:ns:xmpp-streams");
+			local text = stanza:get_child_text("text", "urn:ietf:params:xml:ns:xmpp-streams");
+			error(err.name..(text and ": "..text or ""));
+		else
+			error(stanza and stanza.name or e or "unknown-error");
+		end
 	end
 end