Custom exceptions and formatting

In the demos directory, there are a few different files, including the following.

Shows how to define custom exceptions that are ready to be used by Friendly-traceback. While this is not required, we showed how to support translations.

There is no point in running this file as a script.

This is a demo that generates a few exceptions (most of which are imported from, process them with Friendly-traceback, and shows the result.

This script can be run from a command line.

This is a demo GUI that should be run from a command line.

When importing a script and running it, any normal Python traceback is shown in the console (command line) and the “friendly traceback” counterpart is shown in a text window.

It is suggested that you open “” and run it; you will need to interact from the console (command line) as if you were executing that script from Python.

Note that this GUI could likely be significantly improved; it is included only as a proof of concept. Experienced GUI programmers should feel most welcome to contribute their expertise and make this a more user-friendly demonstration.

A custom formatter which creates an html file from a given exception.

Provides translation support for the demos

Various GUI elements that do not depend on either or friendly_traceback and would only clutter the code of demos if they were included in the script to be run.

Example from the GUI demo running a Custom exception demo

GUI demo

The “simulated” Python traceback is shown in the console on the left; the program pause periodically and ask the user to proceed to the next example.

On the right, we can see the file “” loaded in the editor at the top; at the bottom, we see the custom exception information.

Example output from the custom html formatter demo

Python exception:

NameError: name 'a' is not defined

Likely cause:

In your program, the unknown name is 'a'.

Execution stopped on line 72 of file ''.

       71: try:
    -->72:     b = a + c  # noqa
       73: except Exception:


Note that the information obtained by Friendly-traceback is collected in a “structured” form, as suggested by Aivar Annamaa in Issue8 and noted in Issue10, so that it could be formatted differently by any program using Friendly-traceback.