# HG changeset patch # User Kim Alvefur # Date 1412072308 -7200 # Node ID 69fc23b4481918f2948c3a3a4d6e66abdfd7be15 # Parent 056ccefa6acfcb8b79a3645a19dedac94c202a09 client: Deal with eg no-stream errors where no stanza is passed diff -r 056ccefa6acf -r 69fc23b44819 client.lua --- 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