Created
January 14, 2020 21:22
-
-
Save coreindustries/a0806d66540f0d4cbf5b2b424be86cde to your computer and use it in GitHub Desktop.
Python: unhandled exception handler
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 handle_uncaught_exceptions(e, value, tb): | |
""" https://stackoverflow.com/questions/8050775/using-pythons-logging-module-to-log-all-exceptions-and-errors/8054179#8054179 """ | |
log.exception(f"API Uncaught exception: {e}{value}") | |
traceback.print_tb(tb) | |
sys.excepthook = handle_uncaught_exceptions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment