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

feat(app): implement a global error boundary component #285

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

roy98
Copy link

@roy98 roy98 commented Apr 20, 2022

This Pull Request is associated with this issue #206

  • Implement an error boundary component to handle errors that can corrupt the internal state of React.

  • Display a fallback UI to the user

image

@roy98
Copy link
Author

roy98 commented Apr 20, 2022

@jennydaman can you please have a look?

</Button>
</div>
<div className="illustration-container">
<img src={Illustration} alt="Error illustration" className="illustration" />
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where did this illustration come from? Just want to make sure reuse is permitted.

Or perhaps (in a future issue) we should loop back with @mairin and consider using "brainy" the mascot here (similar to the 404 error page).

Copy link
Author

Choose a reason for hiding this comment

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

The illustration come from undraw

<h2>{this.state.error?.message}</h2>
<p>We are having an issue, please click on the button bellow to reload the page !</p>

<Button id="reload-error-btn" variant="primary" onClick={() => this.reload()}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Currently, the reload function doesn't necessarily reload the page but navigates us back to /. Do you think it would be better to try reloading the page, or navigating "home"? In the latter case, we should instead say here "please click on the button below to go home" (or maybe go back)?

Copy link
Author

@roy98 roy98 May 6, 2022

Choose a reason for hiding this comment

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

Currently, the reload function doesn't necessarily reload the page but navigates us back to /. Do you think it would be better to try reloading the page, or navigating "home"? In the latter case, we should instead say here "please click on the button below to go home" (or maybe go back)?

It would be better to navigate "home". I got your comments

};

reload = () => {
window.location.href = '/';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Pedantic: don't assume web app is served from /, i.e. this will not work if deployed on a subpath (by setting PUBLIC_URL or homepage).

Copy link
Author

Choose a reason for hiding this comment

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

Ok, I will do it then

/>
<div className="container">
<div className="error-message-container">
<h1>400</h1>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not necessarily a 400 error, could be a client-side error.

<div className="error-message-container">
<h1>400</h1>
<h2>{this.state.error?.message}</h2>
<p>We are having an issue, please click on the button bellow to reload the page !</p>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please proofread.

Idea: we should provide a link to https://github.com/FNNDSC/ChRIS_store_ui/issues

return (
<>
<ErrorNotification
key={`notif-boundary`}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does our eslint config allow for unnecessary string template? If so, I should change that.

message={this.state.error?.message || 'Something happened!'}
position="top-right"
variant="danger"
closeable
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is Notification component to use here? If an uncaught exception happens in a child component, I don't think a closable notification would be suitable, we would probably want the entire view to be replaced by an error screen (stop the user from interacting with the program when its state becomes undefined/erroneous)

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.

2 participants