Skip to content

Better error handling - #20

Merged
AnthonyLim23 merged 33 commits into
mainfrom
better-error-handling
Nov 16, 2026
Merged

AnthonyLim23 merged 33 commits into
mainfrom
better-error-handling

Conversation

@alexhroom

Copy link
Copy Markdown
Collaborator

This PR refactors error handling to use a global callback error handler rather than passing strings around. When a callback produces an error, there is now a popup (fixes #16).

This PR also adds a GUIError class which allows errors to both revert parts of the GUI data and also provide a user-friendly message separate to the actual error traceback (which can now be viewed in a 'Show details' tab.

This should make our error handling more consistent as all errors are now caught rather than just ones we have a string for, and also the traceback is now available to users so they can report the error to us with more information.

error-closed error-open

@alexhroom
alexhroom added this pull request to stack #21 October 8, 2026 11:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Cancellation and rollback paths can produce unintended errors, the popup assertion is ineffective, and the required Dash version is undeclared.

4 open findings
What changed in this PR

Refactors callback failures into a centralized modal with user-friendly messages, tracebacks, and GUI rollback support.

Changes:

  • Adds GUIError, a global Dash error handler, and an error-details modal.
  • Migrates presenters and callbacks from returned error strings to exceptions.
  • Updates unit and system tests for the new behavior.
File Description
src/​MNeuEventGUI/​utils/​errors.py Implements centralized error handling and modal UI.
src/​MNeuEventGUI/​main_app/​view.py Registers the handler and modal callbacks.
src/​MNeuEventGUI/​main_app/​presenter.py Converts load/save failures to GUIError.
src/​MNeuEventGUI/​table/​presenter.py Adds table-edit rollback errors.
src/​MNeuEventGUI/​table/​view.py Removes the error-message callback output.
src/​MNeuEventGUI/​time/​presenter.py Raises errors for invalid time edits.
src/​MNeuEventGUI/​log/​presenter.py Raises errors for invalid log edits.
src/​MNeuEventGUI/​filters/​presenter.py Propagates calculation errors globally.
src/​MNeuEventGUI/​filters/​view.py Removes the calculation error output.
src/​MNeuEventGUI/​test_helpers/​gui.py Renames the popup assertion helper.
tests/​utils/​errors_test.py Tests error details, rollback, and modal updates.
tests/​main_app/​main_app_presenter_test.py Tests presenter error conversion and rollback.
tests/​table/​table_presenter_test.py Tests table validation exceptions.
tests/​time/​time_presenter_test.py Tests time-edit rollback exceptions.
tests/​log/​log_presenter_test.py Tests log-edit rollback exceptions.
tests/​filters/​filters_presenter_test.py Updates calculation error expectations.
tests/​system_tests/​load_and_save_test.py Exercises the error popup and details view.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/MNeuEventGUI/main_app/view.py Resolved
Comment thread src/MNeuEventGUI/main_app/presenter.py Resolved
Comment thread src/MNeuEventGUI/main_app/presenter.py Resolved
Comment thread src/MNeuEventGUI/test_helpers/gui.py Resolved
Base automatically changed from swap-out-interface to main November 16, 2026 11:19
@github-actions github-actions Bot added the Has Conflicts This PR has merge conflicts label Nov 16, 2026
@github-actions

Copy link
Copy Markdown

👋 Hi, @alexhroom,

Conflicts have been detected against the base branch. Please rebase your branch against the base branch.


This message is automatically generated by prince-chrismc/label-merge-conflicts-action so don't hesitate to report issues/improvements there.

@AnthonyLim23
AnthonyLim23 removed this pull request from stack #21 November 16, 2026 11:22
@github-actions github-actions Bot removed the Has Conflicts This PR has merge conflicts label Nov 16, 2026
Comment thread src/MNeuEventGUI/log/presenter.py Resolved
Comment thread src/MNeuEventGUI/main_app/presenter.py Resolved
Comment thread src/MNeuEventGUI/table/view.py Outdated
html.Div(id=presenter.ID + '-dropdown-container')
])

@property

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this

Co-authored-by: Anthony <anthony.lim@stfc.ac.uk>
@AnthonyLim23
AnthonyLim23 merged commit d865c3d into main Nov 16, 2026
25 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Swap the warning box for a pop up

3 participants