-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
Wrap <LoadableRenderer /> with <ErrorBoundary /> #6294
Conversation
It appears that since the introduction of <SuperChart />, errors in the visualization javascript (which are somewhat common and expected, especially as we'll support plugins) were not handled and the whole page would throw and go missing. Here I'm introducing a new <ErrorBoundary /> component that elegantly wraps other components and handles errors. It's inspired by: https://reactjs.org/docs/error-boundaries.html The default behavior of the component is to simply surface the error as an <Alert bsStyle="danger" /> and exposes the React stacktrace when clicking on the error. It's also possible to use component and pass an onError handler and not show the default message. This also fixes some minor bugs in TimeTable.
Codecov Report
@@ Coverage Diff @@
## master #6294 +/- ##
=========================================
- Coverage 77.01% 77% -0.02%
=========================================
Files 64 64
Lines 9508 9516 +8
=========================================
+ Hits 7323 7328 +5
- Misses 2185 2188 +3
Continue to review full report at Codecov.
|
const { | ||
columnCollection, |
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.
Can do columnCollection = []
to default to []
|
||
componentDidCatch(error, info) { | ||
this.props.onError(error, info); | ||
this.setState({ hasError: true, error, info }); |
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 hasError
needed? Don't see it being used.
const propTypes = { | ||
children: PropTypes.node.isRequired, | ||
onError: PropTypes.func, | ||
showMessage: PropTypes.boolean, |
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.
PropTypes.bool
queryResponse: PropTypes.object, | ||
message: PropTypes.node.isRequired, | ||
link: PropTypes.string, | ||
stacktrace: PropTypes.string, |
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.
camelcase stackTrace
for consistency with StackTraceMessage
in the class name and showStackTrace
.
+1 |
Oops I think there was a review collision here, I was addressing comments as this got merged. Sending an update. |
* Wrap <LoadableRenderer /> with <ErrorBoundary /> It appears that since the introduction of <SuperChart />, errors in the visualization javascript (which are somewhat common and expected, especially as we'll support plugins) were not handled and the whole page would throw and go missing. Here I'm introducing a new <ErrorBoundary /> component that elegantly wraps other components and handles errors. It's inspired by: https://reactjs.org/docs/error-boundaries.html The default behavior of the component is to simply surface the error as an <Alert bsStyle="danger" /> and exposes the React stacktrace when clicking on the error. It's also possible to use component and pass an onError handler and not show the default message. This also fixes some minor bugs in TimeTable. * Addressing comments
It appears that since the introduction of , errors in the
visualization javascript (which are somewhat common and expected,
especially as we'll support plugins) were not handled and the whole
page would throw and go missing.
Here I'm introducing a new component that elegantly
wraps other
components and handles errors. It's inspired by:
https://reactjs.org/docs/error-boundaries.html
The default behavior of the component is to simply surface the error
as an and exposes the React stacktrace
when clicking on the error.
It's also possible to use component and pass an onError handler and not
show the default message.
This also fixes some minor bugs in TimeTable.