-
-
Notifications
You must be signed in to change notification settings - Fork 405
Closed
Description
Some history first:
componentDidCatch (from react), is a new~ish feature (as of v2 (16)). It is super handy for catching rendering errors in components. Since react is all components, it'd be silly to have componentDidCatch in every component, so what I ended up doing, was making my own Route component (extending from react-router -- very similar to ember's Route, but less structured, no data handling), where an error catcher component wrapped the sub-tree of components.
This provided the following benefits:
- when my data fetching threw an error, such as 401 or 403, I could have a pre-defined shared error-rendering component for a consistent error look and feel throughout the app, and it would be contextual within the sub-page / route -- this is similar to how our error template from routes works today (however, see An alternative to Controllers #499 for using components for error rendering)
- (mainly what this pre-RFC is about) when any component in the sub-tree errored, either because of a malformed template or due to a typical javascript runtime error, such as calling a method on undefined, or accessing a property on undefined, the error message would be caught by the nearest ancestor's
componentDidCatch, so that we may render an appropriate and meaningful error message to not confuse our users and get support requests saying "it's broken, pls send help".
So, my question to the community and core team members:
- what do you think of extending the current route-error catching functionality to include rendering errors?
- what sort of details need to be known for implementation? (I haven't explored that part of the code myself yet)
For reference: examples of errors not caught by the existing error handling mechanisms, and what the consequences are: https://codesandbox.io/s/error-examples-ydped
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels