Add back stanza-specific exception handlers
(fixes the test suite too)
This commit is contained in:
parent
11fbaa4241
commit
74b4ea20bf
@ -706,6 +706,7 @@ class XMLStream(asyncio.BaseProtocol):
|
|||||||
handlers = self.__event_handlers.get(name, [])
|
handlers = self.__event_handlers.get(name, [])
|
||||||
for handler in handlers:
|
for handler in handlers:
|
||||||
handler_callback, disposable = handler
|
handler_callback, disposable = handler
|
||||||
|
old_exception = getattr(data, 'exception', None)
|
||||||
|
|
||||||
# If the callback is a coroutine, schedule it instead of
|
# If the callback is a coroutine, schedule it instead of
|
||||||
# running it directly
|
# running it directly
|
||||||
@ -715,12 +716,18 @@ class XMLStream(asyncio.BaseProtocol):
|
|||||||
try:
|
try:
|
||||||
yield from cb(data)
|
yield from cb(data)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
if old_exception:
|
||||||
|
old_exception(e)
|
||||||
|
else:
|
||||||
self.exception(e)
|
self.exception(e)
|
||||||
asyncio.async(handler_callback_routine(handler_callback))
|
asyncio.async(handler_callback_routine(handler_callback))
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
handler_callback(data)
|
handler_callback(data)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
if old_exception:
|
||||||
|
old_exception(e)
|
||||||
|
else:
|
||||||
self.exception(e)
|
self.exception(e)
|
||||||
if disposable:
|
if disposable:
|
||||||
# If the handler is disposable, we will go ahead and
|
# If the handler is disposable, we will go ahead and
|
||||||
|
Loading…
x
Reference in New Issue
Block a user