Last active
November 15, 2018 08:51
-
-
Save zhuifengshen/bfb4a5d521a811781d3e3404351374af to your computer and use it in GitHub Desktop.
Decorate func with this to prevent raising an Exception when an error is encountered
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 prevent(func): | |
""" | |
Decorate func with this to prevent raising an Exception when an error is encountered | |
""" | |
@wraps(func) | |
def wrapper(*args, **kwargs): | |
try: | |
return func(*args, **kwargs) | |
except BaseException: | |
return | |
return wrapper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment