https://raspberrypifoundation.github.io/python-friendly-error-messages/
This directory contains a demo index.html file that showcases the Python Friendly Error Messages library. This uses a given build of the library.
The demo shows how the library transforms common Python error traces (from both Skulpt and Pyodide runtimes) into friendly, beginner-friendly explanations. It includes examples of:
- NameError: Undefined variables
- SyntaxError: Missing colons and syntax issues
- AttributeError: Wrong method names (e.g.,
.push()instead of.append()) - TypeError: Type mismatches
- UnboundLocalError: Variables used before assignment
- IndexError: List index out of range
- KeyError: Dictionary key not found
- ZeroDivisionError: Division by zero
Each example shows:
- The original Python traceback
- The code that caused the error
- The friendly explanation generated by the library
This is handled automatically on the hosted demo, but to run it locally against a specific version of the library:
Set the version of the library in docs/package.json, then in this docs/ directory run:
- Install the package and prepare the demo:
npm install npm run prepare-demo
Then in the root directory of the project:
-
Start up a local web server:
npx http-server -p 8000
-
Navigate to
http://localhost:8000/docs/local-demo.html
The local-demo.html file in this directory is a copy of the hosted demo that can be run locally, ie. against the local build of the library. Useful for development and testing.
(all commands should be run in the root directory of the project)
-
Make sure the project is built:
npm run build:all
-
Start up a local web server:
npx http-server -p 8000
-
Navigate to
http://localhost:8000/docs/local-demo.html