Handling exceptions inside Observable.fromCallable() when subscription gets cleared

十年热恋 提交于 2019-12-02 11:54:56

Unlike RxJava1, RxJava2 will not deliver this Exception to the Subscriber onError(), as you called cancel() to unsubscribe and don't wan't to get notifications anymore, so this kind of Exceptions which happens with the unsubscription code go by default now to Thread.currentThread().getUncaughtExceptionHandler().uncaughtException().

You can either wrap with try catch this kind of exceptions that may happens with cancel, or override the default behavior with:

RxJavaPlugins.setErrorHandler(Functions.<Throwable>emptyConsumer()); 

or any other handling you would like.

You should also read the full explanation by akarnokd at RxJava github.
Also refer to this discussion for the above mentioned solutions.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!