Software / code / verse
Comparison
client.lua @ 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 |
| parent | 344:ea668c47e1bd |
| child | 400:0db9cb909cf1 |
comparison
equal
deleted
inserted
replaced
| 363:056ccefa6acf | 364:69fc23b44819 |
|---|---|
| 51 return stream:event("stanza", stanza); | 51 return stream:event("stanza", stanza); |
| 52 end | 52 end |
| 53 | 53 |
| 54 function stream_callbacks.error(stream, e, stanza) | 54 function stream_callbacks.error(stream, e, stanza) |
| 55 if stream:event(e, stanza) == nil then | 55 if stream:event(e, stanza) == nil then |
| 56 local err = stanza:get_child(nil, "urn:ietf:params:xml:ns:xmpp-streams"); | 56 if stanza then |
| 57 local text = stanza:get_child_text("text", "urn:ietf:params:xml:ns:xmpp-streams"); | 57 local err = stanza:get_child(nil, "urn:ietf:params:xml:ns:xmpp-streams"); |
| 58 error(err.name..(text and ": "..text or "")); | 58 local text = stanza:get_child_text("text", "urn:ietf:params:xml:ns:xmpp-streams"); |
| 59 error(err.name..(text and ": "..text or "")); | |
| 60 else | |
| 61 error(stanza and stanza.name or e or "unknown-error"); | |
| 62 end | |
| 59 end | 63 end |
| 60 end | 64 end |
| 61 | 65 |
| 62 function stream:reset() | 66 function stream:reset() |
| 63 if self.stream then | 67 if self.stream then |