Skip to content

Instantly share code, notes, and snippets.

@Behoston
Created November 12, 2018 12:31
Show Gist options
  • Save Behoston/1548ffd3c5b03ffb92e8ee34b9d3fbb0 to your computer and use it in GitHub Desktop.
Save Behoston/1548ffd3c5b03ffb92e8ee34b9d3fbb0 to your computer and use it in GitHub Desktop.
Decorator to return exceptions. Applicable to parsing data without fails
def return_exceptions(*exception: Exception):
def decorator(function):
def wrapper(*args, **kwargs):
try:
return function(*args, **kwargs)
except exception as e:
return e
return wrapper
return decorator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment