Change behaviour of on_error
Change how the old style on_error event is called to match the new style on_error event. Both are now called in case an exception is raised in an user defined event handler, and will by default print the arguments of the event tha raised the exception and the traceback for the exception. In addition, overridding the on_error handler supresses this behaviour.
This commit is contained in:
@ -360,7 +360,7 @@ class Client(object):
|
||||
self.events = {
|
||||
'on_ready': _null_event,
|
||||
'on_disconnect': _null_event,
|
||||
'on_error': _null_event,
|
||||
'on_error': self.on_error,
|
||||
'on_response': _null_event,
|
||||
'on_message': _null_event,
|
||||
'on_message_delete': _null_event,
|
||||
@ -457,8 +457,7 @@ class Client(object):
|
||||
log.info('attempting to invoke event {}'.format(event_name))
|
||||
self.events[event_name](*args, **kwargs)
|
||||
except Exception as e:
|
||||
log.error('an error ({}) occurred in event {} so on_error is invoked instead'.format(type(e).__name__, event_name))
|
||||
self.events['on_error'](event_name, *sys.exc_info())
|
||||
self.events['on_error'](event_name, *args, **kwargs)
|
||||
|
||||
def handle_socket_update(self, event, data):
|
||||
method = '_'.join(('handle', event.lower()))
|
||||
|
Reference in New Issue
Block a user