Skip to content

Instantly share code, notes, and snippets.

@search5
Last active September 2, 2020 10:12
Show Gist options
  • Save search5/f89ed92afabfd03a98528cc6a53a1650 to your computer and use it in GitHub Desktop.
Save search5/f89ed92afabfd03a98528cc6a53a1650 to your computer and use it in GitHub Desktop.
python global exception hook
import sys
def my_except_hook(exctype, value, traceback):
if exctype == KeyboardInterrupt:
print("Handler code goes here")
else:
print('Error Send...')
sys.__excepthook__(exctype, value, traceback)
sys.excepthook = my_except_hook
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment