You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We currently aren't providing a way to gracefully handle an error. We do have error handling in the subscription/observer itself, but no way to have the subscription "recover" from a fatal error.
Since subscriptions have ended the moment an error is emitted from an observable, the catch method behaves a lot like catch on promise, meaning that it returns an observable that will switch to whatever observable you map to in its handler in the event of an error.
For example:
// Given this observable that will always error:constsource=button1.on('click').map((e,i)=>{if(i===2){thrownewError('boom!');}returne;});// If we catch the error and return a different observable,// the new observable takes over the subscription.source.catch((err)=>{console.error(err);// let another button take overreturnbutton2.on('click');}).subscribe({next: console.log,error: ()=>{/* never called */}});// If we catch the error and return the same observable, you can// resume or "retry" that observablesource.catch((err)=>{console.log(err);returnsource;}).subscribe({next: console.log,error: ()=>{/* never called */}});// If we catch the error and throw it again, or throw any other error// The resulting observable still errorssource.catch((err)=>{thrownewError('Different error!');}).subscribe({next: console.log,error: console.error});
The text was updated successfully, but these errors were encountered:
We currently aren't providing a way to gracefully handle an error. We do have error handling in the subscription/observer itself, but no way to have the subscription "recover" from a fatal error.
Since subscriptions have ended the moment an error is emitted from an observable, the
catch
method behaves a lot likecatch
on promise, meaning that it returns an observable that will switch to whatever observable you map to in its handler in the event of an error.For example:
The text was updated successfully, but these errors were encountered: