Skip to content

Instantly share code, notes, and snippets.

@SaitTalhaNisanci
Created April 10, 2019 21:45
Show Gist options
  • Save SaitTalhaNisanci/018992235b8b4f39808314ef4b533dae to your computer and use it in GitHub Desktop.
Save SaitTalhaNisanci/018992235b8b4f39808314ef4b533dae to your computer and use it in GitHub Desktop.
Hotjar backend challenge
def log_on_exception(*tags):
"""
A utility decorator to log the exception with
the given tags.
it reraises the exception.
"""
def decorator(function):
@functools.wraps(function)
def wrapper(*args, **kwargs):
try:
return function(*args, **kwargs)
except:
log_message = 'There was an exception in '
log_message += function.__name__
# log the exception
log(log_message, tags)
# re-raise the exception
raise
return wrapper
return decorator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment