-
-
Save gregorynicholas/4597924 to your computer and use it in GitHub Desktop.
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
from werkzeug.debug.tbtools import Traceback | |
from phomp.api.errors import PhompException | |
def wrap_exceptional(f): | |
config = 'default_settings' | |
def wrap(f): | |
def wrapper(*args, **kwargs): | |
try: | |
return f(*args, **kwargs) | |
except Exception: | |
tb = Traceback(*sys.exc_info()) | |
del tb.frames[0] # do not include the wrapper itself | |
Exceptional.publish(config, tb) | |
raise | |
return wrapper | |
if callable(f): | |
return wrap(f) | |
else: | |
config = f | |
return wrap | |
def install_excepthook(config): | |
if getattr(install_excepthook, 'run', False): return | |
install_excepthook.run = True | |
orighook = sys.excepthook | |
def newhook(ty, val, tb): | |
Exceptional.publish(config, Traceback(ty, val, tb)) | |
return orighook(ty, val, tb) | |
sys.excepthook = newhook |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment