Errors travel up the owner tree
An error thrown by an effect, a memo, a cleanup or a child computation goes to the nearest handler on the way up the owner chain.
An error thrown by an effect, a memo, a cleanup or a child computation goes to the nearest handler on the way up the owner chain. Register handlers with onError(handler) (on the current owner) or catchError(fn, handler) (a new scope around fn). Handlers are tried newest first within one owner. A handler that throws passes its own error to the next handler up. An error that reaches the top is uncaught: it is collected and thrown when the running flush or disposal ends.
Handlers belong to one run of their owner: when an effect re-runs, the handlers its previous run registered are discarded, so register onError inside the effect body each time it should apply. The ErrorBoundary component is built from this: see error handling.