Skip to content

Instantly share code, notes, and snippets.

@alexmill
Created August 23, 2018 18:46
Show Gist options
  • Save alexmill/6bcb0790df9745979047d02902704ca8 to your computer and use it in GitHub Desktop.
Save alexmill/6bcb0790df9745979047d02902704ca8 to your computer and use it in GitHub Desktop.
Automatically open tab and search for Python error message on StackOverflow
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