Merge pull request #3450 from ByteHamster/undeliverable-exception

Fixed crashes when leaving search fragments
This commit is contained in:
H. Lehmann 2019-09-26 18:58:04 +02:00 committed by GitHub
commit 25bd5bbeed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 14 deletions

View File

@ -1,12 +1,9 @@
package de.danoeh.antennapod.core.util.exception;
import android.util.Log;
import de.danoeh.antennapod.core.gpoddernet.GpodnetServiceException;
import io.reactivex.exceptions.UndeliverableException;
import io.reactivex.plugins.RxJavaPlugins;
import java.io.InterruptedIOException;
public class RxJavaErrorHandlerSetup {
private RxJavaErrorHandlerSetup() {
@ -14,21 +11,14 @@ public class RxJavaErrorHandlerSetup {
}
public static void setupRxJavaErrorHandler() {
RxJavaPlugins.setErrorHandler(originalCause -> {
Throwable e = originalCause;
RxJavaPlugins.setErrorHandler(e -> {
if (e instanceof UndeliverableException) {
e = e.getCause();
}
if (e instanceof GpodnetServiceException) {
e = e.getCause();
}
if (e instanceof InterruptedException || e instanceof InterruptedIOException) {
// fine, some blocking code was interrupted by a dispose call
Log.d("RxJavaErrorHandler", "Ignored exception: " + Log.getStackTraceString(originalCause));
// Probably just disposed because the fragment was left
Log.d("RxJavaErrorHandler", "Ignored exception: " + Log.getStackTraceString(e));
return;
}
Thread.currentThread().getUncaughtExceptionHandler()
.uncaughtException(Thread.currentThread(), originalCause);
.uncaughtException(Thread.currentThread(), e);
});
}
}