flynn.gg

Christopher Flynn

Machine Learning
Systems Architect,
PhD Mathematician

Home
Projects
Open Source
Blog
Résumé

GitHub
LinkedIn

Blog


excoverflow - Explaining Unhandled Exceptions

2018-02-21 Feed

I came across a reddit post earlier today on /r/ProgrammerHumor. The post links to an image of an unhandled exception and a button that is supposed to link to an explanation on stackoverflow related to the error. I thought that this should exist for python. I went looking around for a package but didn’t find one so I decided to just make one that does something similar.

It’s called excoverflow and I just uploaded it to PyPI. It’s a simple python module that wraps the sys.excepthook function that is called whenever an unhandled exception is raised in python code. After printing the stacktrace and exception, it prints a few more lines to the console containing urls to search results for the exception name and message on google and stackoverflow.

Once installed via pip install excoverflow just import the module, import excoverflow, into any file that you’re developing where you might need stackoverflow or google search results for unexpected errors.

An example test.py

import excoverflow


if __name__ == "__main__":
    # insert unhandled exception here
    val = 5 / 0

produces the following output.

Traceback (most recent call last):
  File "test.py", line 5, in <module>
    val = 5 / 0
ZeroDivisionError: division by zero

https://www.google.com/search?q=python+ZeroDivisionError+division+by+zero
https://stackoverflow.com/search?q=%5Bpython%5D+%22ZeroDivisionError+division+by+zero%22

Further reading

excoverflow

Tools

Python Package Index

Back to the posts.