Skip to content

Commit

Permalink
main.py: Handle uncaught exception with sys.excepthook
Browse files Browse the repository at this point in the history
  • Loading branch information
von committed Apr 5, 2014
1 parent 7b6be15 commit 81d8408
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions python/main.py
Expand Up @@ -10,7 +10,22 @@
from __future__ import print_function # So we can get at print()

import argparse
import pdb
import sys
import traceback


# Handle uncaught exception by opening debugger
# Kudos: Doug Hellman and http://stackoverflow.com/a/6234491/197789
def exception_catcher(type, value, tb):
"""Handle uncaught exceptions
Intended to be used for sys.excepthook"""
traceback.print_exc()
pdb.post_mortem(tb)

sys.excepthook = exception_catcher


# Output functions
output = print
Expand Down

0 comments on commit 81d8408

Please sign in to comment.