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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.198.94