Add improved error messaging to python projects#1483
Conversation
|
|
There was a problem hiding this comment.
Pull request overview
This PR adds an optional “friendly errors” feature for Python projects by integrating @raspberrypifoundation/python-friendly-error-messages (pfem), wiring a new friendly_errors_enabled web-component attribute through Redux into both Python runners, and extending the error UI to display the friendly title/summary.
Changes:
- Add pfem dependency and bundle its copydecks into the build output.
- Introduce
friendlyErrorsEnabled+friendlyErrorRedux state and plumb the flag intoPyodideRunnerandSkulptRunner. - Extend
ErrorMessageto render pfem’s friendly title/summary and adjust Jest config/mocks to accommodate the new dependency (plus plotly mocking updates).
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| yarn.lock | Locks pfem dependency version. |
| package.json | Adds pfem dependency; adjusts Jest transformIgnorePatterns and test script. |
| webpack.config.js | Adds resolve rule for pfem and copies pfem copydecks into build output. |
| src/web-component.js | Adds friendly_errors_enabled as an observed boolean attribute. |
| src/containers/WebComponentLoader.jsx | Dispatches the new friendlyErrorsEnabled flag into Redux. |
| src/redux/EditorSlice.js | Adds Redux state + actions for friendly error support. |
| src/components/Editor/Runners/PythonRunner/PythonRunner.jsx | Passes friendlyErrorsEnabled into both Python runners. |
| src/components/Editor/Runners/PythonRunner/PyodideRunner/PyodideRunner.jsx | Initializes pfem for Pyodide and stores friendly error output. |
| src/components/Editor/Runners/PythonRunner/SkulptRunner/SkulptRunner.jsx | Initializes pfem for Skulpt and stores friendly error output. |
| src/components/Editor/ErrorMessage/ErrorMessage.jsx | Renders friendly error title/summary in the error panel. |
| src/utils/setupTests.js | Adds Jest mocks for pfem and plotly. |
| src/components/Editor/Runners/PythonRunner/PyodideRunner/VisualOutputPane.test.js | Updates plotly expectations to assert Plotly calls. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mwtrew
left a comment
There was a problem hiding this comment.
Looking great in general! A few comments/questions but I'm happy for it to go in.
…ion and small refactor for plotly test
Part of https://github.com/RaspberryPiFoundation/digital-editor-issues/issues/1448
Changes
friendly_errors_enabledattribute set tofalseby default and added to reduxBehaviour
When the editor-wc in the host app has

friendly_errors_enabledattribute not set or set tofalse, it shows the original error.When the editor-wc in the host has

friendly_errors_enabledattribute set totrue, it shows the original error followed by title and summary of the new friendly error.Notes on using the pfem ESM in Jest
jest.transformIgnorePatternsin package.json, but resulted in a cascade of errors from plotlythreetojest.transformIgnorePatternsfromscripts.testsetupTests.jsPyodideRunner/VisualOutputPane.test.js