catchError, onError and handleError
catchError, onError and handleError in the Error handling guide.
These three share one routing mechanism. Every owner (a component, effect, memo, root or scope) may carry error handlers. When something throws inside an owner's computation, the error goes to the handlers of the nearest owner that has any, walking up through parents.
catchError(fn, handler)runsfnin a new child scope that hashandler. Iffnthrows synchronously,handleris called andcatchErrorreturnsundefined. Errors thrown later by effects, memos and cleanups created inside also go tohandler.onError(handler)adds a handler to the current owner. It receives errors from that owner's descendants that no closer handler took. With no owner it warnsNO_OWNER_ERROR. Handlers added to an effect or memo last for one run: they are cleared when it re-runs.- Several handlers on one owner are tried newest first. A handler that returns normally handled the error. A handler that throws passes its own error on: to the next handler, then up to the parents.
handleError(error, owner)from@shadow-js/core/extendstarts the same routing by hand, from the owner you pass. Use it after anawait, in a timer or in an event handler to send a failure into the boundary tree.