|
|
@ -12,6 +12,9 @@ import androidx.multidex.MultiDexApplication; |
|
|
|
import com.crashlytics.android.Crashlytics; |
|
|
|
import com.zoyi.channel.plugin.android.ChannelIO; |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.net.SocketException; |
|
|
|
|
|
|
|
import io.fabric.sdk.android.Fabric; |
|
|
|
import io.reactivex.exceptions.UndeliverableException; |
|
|
|
import io.reactivex.plugins.RxJavaPlugins; |
|
|
@ -40,12 +43,30 @@ public class GmeApplication extends MultiDexApplication { |
|
|
|
Fabric.with(this, new Crashlytics()); |
|
|
|
} |
|
|
|
|
|
|
|
RxJavaPlugins.setErrorHandler(throwable -> { |
|
|
|
if (throwable instanceof UndeliverableException && throwable.getCause() instanceof HttpException) { |
|
|
|
return; // ignore BleExceptions as they were surely delivered at least once |
|
|
|
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; |
|
|
|
} |
|
|
|
// add other custom handlers if needed |
|
|
|
throw new RuntimeException("Unexpected Throwable in RxJavaPlugins error handler", throwable); |
|
|
|
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; |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|