Do not crash when cancelling gpodder podcast loading
This commit is contained in:
parent
a08105df2b
commit
7cc5f86979
@ -1,6 +1,7 @@
|
||||
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;
|
||||
|
||||
@ -13,16 +14,21 @@ public class RxJavaErrorHandlerSetup {
|
||||
}
|
||||
|
||||
public static void setupRxJavaErrorHandler() {
|
||||
RxJavaPlugins.setErrorHandler(e -> {
|
||||
RxJavaPlugins.setErrorHandler(originalCause -> {
|
||||
Throwable e = originalCause;
|
||||
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(e));
|
||||
Log.d("RxJavaErrorHandler", "Ignored exception: " + Log.getStackTraceString(originalCause));
|
||||
return;
|
||||
}
|
||||
Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e);
|
||||
Thread.currentThread().getUncaughtExceptionHandler()
|
||||
.uncaughtException(Thread.currentThread(), originalCause);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user