Skip to content
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.

Commit

Permalink
fix: catch exception in hook function
Browse files Browse the repository at this point in the history
  • Loading branch information
hanhxiao committed Sep 23, 2019
1 parent 402867c commit c6ecefa
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion gnes/service/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,12 @@ def call_hooks(self, msg: 'gnes_pb2.Message', hook_type: Union[str, Tuple[str]],

for fn, only_verbose in hooks:
if (only_verbose and self.service_context.args.verbose) or (not only_verbose):
fn(self.service_context, msg, *args, **kwargs)
try:
fn(self.service_context, msg, *args, **kwargs)
except Exception as ex:
self.logger.warning('hook %s throws an exception, '
'this wont affect the server but you may want to pay attention' % fn)
self.logger.error(ex, exc_info=True)

def call_routes(self, msg: 'gnes_pb2.Message'):
def get_default_fn(m_type):
Expand Down

0 comments on commit c6ecefa

Please sign in to comment.