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 RxJava plugins

A possible alternative to the former approach (or an improvement) is the use of the following call:

RxJavaPlugins.setErrorHandler(...);

It will set a global handler for all the exceptions (or errors) that weren't caught by the mechanisms provided by the Observable flow.

Since RxJavaPlugins.setErrorHandler consumes the Consumer<Throwable> interface, we might as well plug in the class we just created to do the actual handling of the errors:

RxJavaPlugins.setErrorHandler(ErrorHandler.get());

Now, all the errors will go through this final handler if they aren't captured earlier.

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