Changeset

336:658c62c9ecc4

verse.client: Fire stream error events, so they can be handled
author Kim Alvefur <zash@zash.se>
date Mon, 29 Apr 2013 10:58:40 +0200
parents 335:9e69ee8542d4
children 337:8dce8240a77c
files client.lua
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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();