hyperapp: Error Handling
Please forgive me if we’ve already had a discussion on this topic, and I know this is subject to change with the API proposals brewing, but I wanted to capture the state of affairs as of this moment.
Because of the indirection with events.action
and events.resolve
it’s not possible to catch any errors that are thrown within the execution of an action today. I believe the same will also hold true for the coming hooks
API.
It is possible to catch and handle view errors with an HOC.
React 16 is introducing Error Boundaries to handle this problem. I’m not proposing we add anything to core, but wondering what the best practice should be.
Here’s a small demo pen showing view/sync action/async action errors and how one might handle them with an HOA: https://codepen.io/okwolf/pen/rGWpgJ?editors=0010
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 6
- Comments: 29 (26 by maintainers)
Guys,
is a joke. A bad one. 🙇
h('h1', { onerror: () => console.log("Can't you recognize sarcasm when you see it!?") }, 'What could possible go wrong?')
@johanalkstal @okwolf What about a new VDOM event?
@JorgeBucaran give me some time to update the examples for 1.0.0, then we can discuss. I still don’t think we should add anything to core just yet.
I think there are several types of errors to consider:
view
which are synchronous during render. If this happens, it is unclear if the app can continue due to unknown render state.actions
which can be synchronous or asynchronous.window.onerror
.