Error Handling Operators

David Gross edited this page Jan 12, 2015 · 28 revisions

There are a variety of operators that you can use to react to or recover from onError notifications from Observables. For example, you might:

  1. swallow the error and switch over to a backup Observable to continue the sequence
  2. swallow the error and emit a default item
  3. swallow the error and immediately try to restart the failed Observable
  4. swallow the error and try to restart the failed Observable after some back-off interval

The following pages explain these operators.

  • onErrorResumeNext( ) — instructs an Observable to emit a sequence of items if it encounters an error
  • onErrorReturn( ) — instructs an Observable to emit a particular item when it encounters an error
  • onExceptionResumeNext( ) — instructs an Observable to continue emitting items after it encounters an exception (but not another variety of throwable)
  • retry( ) — if a source Observable emits an error, resubscribe to it in the hopes that it will complete without error
  • retryWhen( ) — if a source Observable emits an error, pass that error to another Observable to determine whether to resubscribe to the source
You can’t perform that action at this time.
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.
Press h to open a hovercard with more details.