版权声明:本文为楠之枫雪的原创文章,未经博主允许不得转载。 https://blog.csdn.net/u014614038/article/details/80898449
出现异常:io.reactivex.exceptions.UndeliverableException
出现原因:调用了多次onError,正常来说,出现一次onError会走正常Observer处理,其他的会走Error handling ,可以通过以下捕捉多次的error:
RxJavaPlugins.setErrorHandler(new Consumer<Throwable>() {
@Override
public void accept(Throwable e) {
if (e instanceof UndeliverableException) {
e = e.getCause();
}
if ((e instanceof IOException)) {
// fine, irrelevant network problem or API that throws on cancellation
return;
}
if (e instanceof InterruptedException) {
// fine, some blocking code was interrupted by a dispose call
return;
}
if ((e instanceof NullPointerException) || (e instanceof IllegalArgumentException)) {
// that's likely a bug in the application
Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e);
return;
}
if (e instanceof IllegalStateException) {
// that's a bug in RxJava or in a custom operator
Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e);
return;
}
Logger.l("Undeliverable exception");
}
});