onErrorResume method

Observable<T> onErrorResume(
  1. Stream<T> recoveryFn(
    1. dynamic error

Intercepts error events and switches to a recovery stream created by the provided recoveryFn.

The onErrorResume operator intercepts an onError notification from the source Observable. Instead of passing the error through to any listeners, it replaces it with another Stream of items created by the recoveryFn.

The recoveryFn receives the emitted error and returns a Stream. You can perform logic in the recoveryFn to return different Streams based on the type of error that was emitted.

If you do not need to perform logic based on the type of error that was emitted, please consider using onErrorResumeNext or onErrorReturn.


new Observable<int>.error(new Exception())
  .onErrorResume((dynamic e) =>
      new Observable.just(e is StateError ? 1 : 0)
  .listen(print); // prints 0


Observable<T> onErrorResume(Stream<T> Function(dynamic error) recoveryFn) =>