Created
November 12, 2018 12:31
-
-
Save Behoston/1548ffd3c5b03ffb92e8ee34b9d3fbb0 to your computer and use it in GitHub Desktop.
Decorator to return exceptions. Applicable to parsing data without fails
This file contains hidden or 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 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