verse.client: Fire stream error events, so they can be handled

Mon, 29 Apr 2013 10:58:40 +0200

author
Kim Alvefur <zash@zash.se>
date
Mon, 29 Apr 2013 10:58:40 +0200
changeset 336
658c62c9ecc4
parent 335
9e69ee8542d4
child 337
8dce8240a77c

verse.client: Fire stream error events, so they can be handled

client.lua file | annotate | diff | comparison | revisions
--- a/client.lua	Fri Feb 15 20:45:31 2013 +0100
+++ b/client.lua	Mon Apr 29 10:58:40 2013 +0200
@@ -51,6 +51,14 @@
 	return stream:event("stanza", stanza);
 end
 
+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));
+	end
+end
+
 function stream:reset()
 	if self.stream then
 		self.stream:reset();

mercurial