Skip to main content

Human-readable HTML tracebacks for Python exceptions

Project description

Nicer error messages for Python

Other languages such as C++ have gotten quite useful error messages and diagnostics with tips on how the fix the problems but Python is still stuck with the bare stacktraces that are very intimidating and often not very helpful.

TraceRite TraceRite backtrace shows where the user has terminated the program.

TraceRite hides the irrelevant IPython/notebook internals and concisely shows what happened (the program was interrupted) and where that happened. This could further be improved by converting the KeyboardInterrupt message into something more suitable, like "You stopped the program", but what you see above is just the default handling that never considered this particular error.

Although IPython and Google Colab developers have done their tweaks to improve backtraces, it is all too apparent that much remains to be done:

Colab Standard backtrace from Google Colab.

Even for the experienced programmer, it is tedious to read through the wall of text to find the relevant details of what went wrong.

In more complex situations where one might get many screenfuls of standard traceback, TraceRite produces scrollable outputs that concentrate on the relevant details but also provide variable inspectors on each frame where it may be relevant:

Nested exceptions TraceRite output with nested exceptions.

Usage

At the beginning of your Notebook:

%pip install tracerite
%load_ext tracerite

Background

This project is a proof of concept, showing a modern way to format error messages in a human-readable manner. Heuristics are used to hide (by default) irrelevant stack frames and show the actual location of the problem. Since it would otherwise be impossible to find out the variable contents after the program has crashed, a variable inspector built into each stack frame quickly reveals problems with the variables mentioned at the source of error. Care is taken to add revelant details such as notebook input field numbers and class names not normally present in Python tracebacks, while hiding overly long paths and other clutter.

All output is in HTML and as such only works in Jupyter notebooks and other browser-based systems (this should be useful for web development frameworks as well). This allows interactivity and much better layout than that of the text console.

License

Public Domain or equivalent.

Help wanted

I won't be able to maintain this all by myself. If you like the idea of nicer tracebacks, please offer your help in development! Pull requests are welcome but it would be even better if you could pick up the whole project as your own.

As of now, this project is in no way properly polished for release. Yet, it is useful enough to such a degree that I always use it in my notebooks, and it really makes Python development a much smoother experience.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tracerite-1.1.0.tar.gz (269.4 kB view details)

Uploaded Source

Built Distribution

tracerite-1.1.0-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file tracerite-1.1.0.tar.gz.

File metadata

  • Download URL: tracerite-1.1.0.tar.gz
  • Upload date:
  • Size: 269.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for tracerite-1.1.0.tar.gz
Algorithm Hash digest
SHA256 041dab8fd4bb405f73506293ac7438a2d311e5f9044378ba7d9a6540392f9e4b
MD5 a252f982ae51a127a9482dc661fb40bf
BLAKE2b-256 db51af42743be894ded783d85b192785b396b1bef019862d5d24783b8fb97eaf

See more details on using hashes here.

File details

Details for the file tracerite-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: tracerite-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for tracerite-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4cccac04db05eeeabda45e72b57199e147fa2f73cf64d89cfd625df321bd2ab6
MD5 1499f34c8c795232d9e6162edb19db01
BLAKE2b-256 6f175cb3c7062752665f75b2bb32df59a5dd13ac535edaa65e1c23b929c165d8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page