Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MNT] Implemented error boundary #406

Merged
merged 5 commits into from
Dec 19, 2024
Merged

[MNT] Implemented error boundary #406

merged 5 commits into from
Dec 19, 2024

Conversation

rmanaem
Copy link
Contributor

@rmanaem rmanaem commented Dec 17, 2024

image

NOTE: If this pull request is to be released, the release label must be applied once the review process is done to avoid the local and remote from going out of sync as a consequence of the bump version workflow run

Checklist

This section is for the PR reviewer

  • PR has an interpretable title with a prefix ([ENH], [FIX], [REF], [TST], [CI], [MNT], [INF], [MODEL], [DOC]) (see our Contributing Guidelines for more info)
  • PR has a label for the release changelog or skip-release (to be applied by maintainers only)
  • PR links to GitHub issue with mention Closes #XXXX
  • Tests pass
  • Checks pass
  • If the PR changes the participant-level and/or the dataset-level result file, the query-tool-results files in the neurobagel_examples repo have been regenerated

For new features:

  • Tests have been added

For bug fixes:

  • There is at least one test that would fail under the original bug conditions.

Summary by Sourcery

Implement an ErrorBoundary component to enhance error handling in the application by wrapping the main component, ensuring that errors are caught and displayed with a user-friendly message.

New Features:

  • Introduce an ErrorBoundary component to handle errors gracefully in the application.

Enhancements:

  • Wrap the main application component with the ErrorBoundary to catch and display errors.

Copy link

sourcery-ai bot commented Dec 17, 2024

Reviewer's Guide by Sourcery

This PR implements an error boundary component to handle runtime errors gracefully. The error boundary is implemented as a class component that catches JavaScript errors anywhere in the component tree and displays a fallback UI with the Neurobagel logo and an error message that directs users to the GitHub issues page.

Class diagram for the new ErrorBoundary component

classDiagram
    class ErrorBoundary {
        - boolean hasError
        + constructor(props: ErrorBoundaryProps)
        + static getDerivedStateFromError(): ErrorBoundaryState
        + componentDidCatch(error: Error, info: React.ErrorInfo): void
        + render(): React.ReactNode
    }

    class ErrorBoundaryProps {
        React.ReactNode children
    }

    class ErrorBoundaryState {
        boolean hasError
    }

    ErrorBoundary --> ErrorBoundaryProps
    ErrorBoundary --> ErrorBoundaryState
Loading

File-Level Changes

Change Details Files
Implementation of the error boundary component
  • Created a class component that implements error boundary lifecycle methods
  • Added error state management and error catching functionality
  • Implemented a fallback UI with logo, message, and GitHub issues link
  • Added TypeScript types for props and state
src/components/ErrorBoundary.tsx
Integration of error boundary into the app
  • Wrapped the main app content with the ErrorBoundary component
  • Maintained proper nesting order with other providers (StyledEngineProvider and ThemeProvider)
src/main.tsx

Assessment against linked issues

Issue Objective Addressed Explanation
#95 Implement error boundary to show a 'This should not have happened' page when app breaks
#95 Include a link to open an issue on the error page
#95 Include appzi feedback scriptlet on the error page The PR implements the error boundary and issue link, but does not include the appzi feedback scriptlet on the error page

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

netlify bot commented Dec 17, 2024

Deploy Preview for neurobagel-query ready!

Name Link
🔨 Latest commit 07ea8df
🔍 Latest deploy log https://app.netlify.com/sites/neurobagel-query/deploys/67635a322be9ea00086f9f7a
😎 Deploy Preview https://deploy-preview-406--neurobagel-query.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@surchs surchs self-requested a review December 18, 2024 02:36
@rmanaem rmanaem added the pr-minor Non-breaking feature or enhancement, will increment minor version (0.+1.0) label Dec 18, 2024
Copy link
Contributor

@surchs surchs left a comment

Choose a reason for hiding this comment

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

Thanks @rmanaem, this looks awesome!

🧑‍🍳

Copy link
Contributor

@surchs surchs left a comment

Choose a reason for hiding this comment

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

🧑‍🍳

@surchs
Copy link
Contributor

surchs commented Dec 18, 2024

Oh, @rmanaem I think we should release off of this PR so we can finally get the synced results files into the deployed app: #389

@surchs surchs added the release Create a release when this PR is merged label Dec 18, 2024
@rmanaem rmanaem merged commit 898a3cc into main Dec 19, 2024
9 checks passed
@rmanaem rmanaem deleted the maint-95 branch December 19, 2024 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-minor Non-breaking feature or enhancement, will increment minor version (0.+1.0) release Create a release when this PR is merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ENH] Adopt Error boundary
2 participants