Skip to content

Instantly share code, notes, and snippets.

@wolph
Forked from jorenham/main.py
Last active Jan 18, 2018
Embed
What would you like to do?
Best exception handling in Python
import sys
import webbrowser
def main():
return 42/0
def excepthook(type_, value, traceback):
webbrowser.open_new_tab('https://stackoverflow.com/search?q=[python] {} {}'.format(type_, value))
sys.__excepthook__(type_, value, traceback)
sys.excepthook = excepthook
if __name__== '__main__':
main()