-
Notifications
You must be signed in to change notification settings - Fork 49
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
base: master
Are you sure you want to change the base?
Conversation
@jennydaman can you please have a look? |
</Button> | ||
</div> | ||
<div className="illustration-container"> | ||
<img src={Illustration} alt="Error illustration" className="illustration" /> |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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()}> |
There was a problem hiding this comment.
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)?
There was a problem hiding this comment.
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 = '/'; |
There was a problem hiding this comment.
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
).
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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`} |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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)
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