O'Reilly logo

Reactive Android Programming by Tadas Subonis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using onExceptionResumeNext()

onExceptionResumeNext() is a great way to restore the flow processing from some other Observable after an exception has occurred. It can be used as a mechanism to plug in the backup Observable if the original one fails. That's exactly what we will do in later sections to handle the cases when we cannot fetch the new stock quote data from the remote service.

However, let's get back to onExceptionResumeNext(), and let's take a look at example of how it can be used:

Observable.<String>error(new RuntimeException("Crash!"))        .onExceptionResumeNext(Observable.just("Second"))        .subscribe(item -> {            log("subscribe", item);        }, e -> log("subscribe", e));

This time, we won't see any exceptions in the logs and the second ( ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required