mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-12-02 19:19:54 +00:00
RootStanza raises unexpected exceptions
We now raise the unexpected exceptions instead of sending them on the network. - avoids flood (sending a traceback on a MUC, for example…) and maybe some security issues. - lets you handle the traceback (catch it to handle it properly, or with except_hook, etc) - an exception cannot be raised without you knowing
This commit is contained in:
parent
0aee445e69
commit
982bf3b2ec
1 changed files with 10 additions and 9 deletions
|
@ -54,16 +54,17 @@ class RootStanza(StanzaBase):
|
||||||
e.extension_args)
|
e.extension_args)
|
||||||
self['error'].append(extxml)
|
self['error'].append(extxml)
|
||||||
self['error']['type'] = e.etype
|
self['error']['type'] = e.etype
|
||||||
|
self.send()
|
||||||
else:
|
else:
|
||||||
# We probably didn't raise this on purpose, so send a traceback
|
# We probably didn't raise this on purpose, so send an error stanza
|
||||||
self['error']['condition'] = 'undefined-condition'
|
self['error']['condition'] = 'undefined-condition'
|
||||||
if sys.version_info < (3, 0):
|
self['error']['text'] = "SleekXMPP got into trouble."
|
||||||
self['error']['text'] = "SleekXMPP got into trouble."
|
self.send()
|
||||||
else:
|
# log the error
|
||||||
self['error']['text'] = traceback.format_tb(e.__traceback__)
|
log.exception('Error handling {%s}%s stanza' %
|
||||||
log.exception('Error handling {%s}%s stanza' %
|
(self.namespace, self.name))
|
||||||
(self.namespace, self.name))
|
# Finally raise the exception, so it can be handled (or not)
|
||||||
self.send()
|
# at a higher level
|
||||||
|
raise e
|
||||||
|
|
||||||
register_stanza_plugin(RootStanza, Error)
|
register_stanza_plugin(RootStanza, Error)
|
||||||
|
|
Loading…
Reference in a new issue