Add improved error messaging to python projects#1483
Open
cocomarine wants to merge 14 commits into
Open
Conversation
Contributor
|
|
Contributor
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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