我对 RxJava 全局处理程序和 Android Vitals 有疑问。在 Android Vitals 我可以看到
io.reactivex.exceptions.UndeliverableException
引起:java.lang.InterruptedException:在 com.google.common.util.concurrent.AbstractFuture.get (AbstractFuture.java:527) 在 com.google.common.util.concurrent.FluentFuture$TrustedFuture.get (FluentFuture.java :82)
但是我已经不知道问题出在哪里了,所以我考虑添加 RxJava 全局错误处理程序:
RxJavaPlugins.setErrorHandler(e -> {
if (e instanceof UndeliverableException) {
e = e.getCause();
}
if ((e instanceof IOException) || (e instanceof SocketException)) {
// 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()
.handleException(Thread.currentThread(), e);
return;
}
if (e instanceof IllegalStateException) {
// that's a bug in RxJava or in a custom operator
Thread.currentThread().getUncaughtExceptionHandler()
.handleException(Thread.currentThread(), e);
return;
}
Log.warning("Undeliverable exception received, not sure what to do", e);
});
还有我的问题。如果我要添加全局错误处理程序,我会丢失来自 Android Vitals 的报告吗?丢失的意思是不会有新的报告,因为我们将处理导致崩溃的错误。
是否可以添加全局错误处理程序并仍然在 Android Vitals 中获得报告?