XMPPError exceptions can keep a stanza's contents.

This allows exceptions to include the original
content of a stanza in the error response by including
the parameter clear=False when raising the exception.
This commit is contained in:
Lance Stout
2011-02-11 15:20:26 -05:00
parent c4b1212c44
commit 0d32638379
7 changed files with 71 additions and 12 deletions
+2 -1
View File
@@ -43,8 +43,8 @@ class RootStanza(StanzaBase):
Arguments:
e -- Exception object
"""
self.reply()
if isinstance(e, XMPPError):
self.reply(clear=e.clear)
# We raised this deliberately
self['error']['condition'] = e.condition
self['error']['text'] = e.text
@@ -56,6 +56,7 @@ class RootStanza(StanzaBase):
self['error']['type'] = e.etype
self.send()
else:
self.reply()
# We probably didn't raise this on purpose, so send an error stanza
self['error']['condition'] = 'undefined-condition'
self['error']['text'] = "SleekXMPP got into trouble."