Skip to content

Instantly share code, notes, and snippets.

@Dulani
Forked from maphew/friendly_traceback.py
Last active October 25, 2019 02:04
Show Gist options
  • Save Dulani/74e5b5dccb7d16cddeee6c96f83041e0 to your computer and use it in GitHub Desktop.
Save Dulani/74e5b5dccb7d16cddeee6c96f83041e0 to your computer and use it in GitHub Desktop.
import sys
debug = True
def exceptionHandler(exception_type, exception, traceback, debug_hook=sys.excepthook):
'''Print user friendly error messages normally, full traceback if DEBUG on.
Adapted from http://stackoverflow.com/questions/27674602/hide-traceback-unless-a-debug-flag-is-set
'''
if debug:
print('\n*** Error:')
# raise
debug_hook(exception_type, exception, traceback)
else:
print ("\t%s: %s" % (exception_type.__name__, exception))
sys.excepthook = exceptionHandler
if __name__ == '__main__':
their_md5 = 'c38f03d2b7160f891fc36ec776ca4685'
my_md5 = 'c64e53bbb108a1c65e31eb4d1bb8e3b7'
if their_md5 != my_md5:
raise ValueError('md5 sum does not match!')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment