> onError中订阅者捕获的错误
>由RxJavaPlugins.setErrorHandler设置的处理程序全局捕获错误
我很难理解为什么会这样.问题:
>让两个处理程序出错的理由是什么?
>是什么导致错误被发送到一个处理程序与另一个处理程序?
>如何确保仅将错误发送到onError?
最佳答案
对于Rx2所做的更改,您可以在Wiki pages上找到大多数设计决策:
One important design requirement for 2.x is that no @H_301_20@Throwable errors should be swallowed. This means errors that can’t be emitted because the downstream’s lifecycle already reached its terminal state or the downstream cancelled a sequence which was about to emit an error.
要确保错误仅由观察者的onError()使用者处理,您必须将全局处理程序设置为空的使用者:
@H_301_20@RxJavaPlugins.setErrorHandler(emptyConsumer());