Skip to content

Instantly share code, notes, and snippets.

@chiendo97
Created February 20, 2023 15:27
Show Gist options
  • Save chiendo97/d53994d4e9cc48d4a4f299131e1fc8d7 to your computer and use it in GitHub Desktop.
Save chiendo97/d53994d4e9cc48d4a4f299131e1fc8d7 to your computer and use it in GitHub Desktop.
catch_exception
def catch_exception(func):
def inner_function(*args, **kwargs):
# return func(*args, **kwargs)
try:
return func(*args, **kwargs)
except grpc._channel._InactiveRpcError as e:
# print(e.details())
# print(args, kwargs)
args[2].abort(e.code(), details=f"Greeter:{func.__name__} -> {e.details()}")
# raise Exception(f"Greeter: {e.code()}-{e.details()}")
return inner_function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment