Preserve ID for error responses

Fixes #319
This commit is contained in:
Lance Stout 2014-09-09 08:49:37 -07:00
parent aabec8b993
commit f22d8e67b4

View File

@ -60,7 +60,9 @@ class RootStanza(StanzaBase):
self.send() self.send()
elif isinstance(e, XMPPError): elif isinstance(e, XMPPError):
# We raised this deliberately # We raised this deliberately
keep_id = self['id']
self.reply(clear=e.clear) self.reply(clear=e.clear)
self['id'] = keep_id
self['error']['condition'] = e.condition self['error']['condition'] = e.condition
self['error']['text'] = e.text self['error']['text'] = e.text
self['error']['type'] = e.etype self['error']['type'] = e.etype
@ -72,7 +74,9 @@ class RootStanza(StanzaBase):
self.send() self.send()
else: else:
# We probably didn't raise this on purpose, so send an error stanza # We probably didn't raise this on purpose, so send an error stanza
keep_id = self['id']
self.reply() self.reply()
self['id'] = keep_id
self['error']['condition'] = 'undefined-condition' self['error']['condition'] = 'undefined-condition'
self['error']['text'] = "SleekXMPP got into trouble." self['error']['text'] = "SleekXMPP got into trouble."
self['error']['type'] = 'cancel' self['error']['type'] = 'cancel'