Skip to content

Instantly share code, notes, and snippets.

@wolph
Forked from jorenham/main.py
Last active January 18, 2018 20:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wolph/88e3222ac57d9c3bff113ff83afddda4 to your computer and use it in GitHub Desktop.
Save wolph/88e3222ac57d9c3bff113ff83afddda4 to your computer and use it in GitHub Desktop.
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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment