Browse Source

Undeliverable exception handled for parallel api calls

master
Preyea Regmi 5 years ago
parent
commit
428640162c
  1. 11
      app/src/main/java/com/gmeremit/online/gmeremittance_native/GmeApplication.java
  2. 9
      app/src/main/java/com/gmeremit/online/gmeremittance_native/topup/local/presenter/topup/LocalTopUpPresenter.java

11
app/src/main/java/com/gmeremit/online/gmeremittance_native/GmeApplication.java

@ -13,6 +13,9 @@ import com.crashlytics.android.Crashlytics;
import com.zoyi.channel.plugin.android.ChannelIO;
import io.fabric.sdk.android.Fabric;
import io.reactivex.exceptions.UndeliverableException;
import io.reactivex.plugins.RxJavaPlugins;
import retrofit2.HttpException;
import static com.gmeremit.online.gmeremittance_native.base.PrefKeys.USER_PREFERRED_COUNTRY_CODE;
@ -37,6 +40,14 @@ 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
}
// add other custom handlers if needed
throw new RuntimeException("Unexpected Throwable in RxJavaPlugins error handler", throwable);
});
if (stringExtractor == null)
stringExtractor = new StringExtractor(getResources());

9
app/src/main/java/com/gmeremit/online/gmeremittance_native/topup/local/presenter/topup/LocalTopUpPresenter.java

@ -64,15 +64,6 @@ public class LocalTopUpPresenter extends BasePresenter implements LocalTopUpPres
this.regularTopUpValidator = new RegularTopUpValidator();
this.fixedTopUpValidator = new FixedTopUpValidator();
this.dataTopUpValidator = new DataTopUpValidator();
RxJavaPlugins.setErrorHandler(throwable -> {
if (throwable instanceof UndeliverableException && throwable.getCause() instanceof HttpException) {
return; // ignore BleExceptions as they were surely delivered at least once
}
// add other custom handlers if needed
throw new RuntimeException("Unexpected Throwable in RxJavaPlugins error handler", throwable);
});
}
@Override

Loading…
Cancel
Save