Skip to content

Instantly share code, notes, and snippets.

@coreindustries
Created January 14, 2020 21:22
Show Gist options
  • Save coreindustries/a0806d66540f0d4cbf5b2b424be86cde to your computer and use it in GitHub Desktop.
Save coreindustries/a0806d66540f0d4cbf5b2b424be86cde to your computer and use it in GitHub Desktop.
Python: unhandled exception handler
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