Created
August 23, 2018 18:46
-
-
Save alexmill/6bcb0790df9745979047d02902704ca8 to your computer and use it in GitHub Desktop.
Automatically open tab and search for Python error message on StackOverflow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def handler(e): | |
import sys, urllib.parse, webbrowser | |
et = sys.exc_info()[0] | |
q = urllib.parse.quote_plus('"{}: {}" site:stackoverflow.com'.format(str(et)[8:-2], e)) | |
u = "https://www.google.com/search?q={}".format(q) | |
webbrowser.open_new_tab(u) | |
try: | |
1/0 | |
except Exception as e: | |
handler(e) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment