Created
April 10, 2019 21:45
-
-
Save SaitTalhaNisanci/018992235b8b4f39808314ef4b533dae to your computer and use it in GitHub Desktop.
Hotjar backend challenge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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