[config][android] Explicitly handle task exception

This commit is contained in:
Elliot Hesp 2018-07-12 13:28:58 +01:00
parent 01c274a2f1
commit 54743d945d
1 changed files with 6 additions and 1 deletions

View File

@ -16,6 +16,7 @@ import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.google.firebase.FirebaseApp;
import com.google.firebase.remoteconfig.FirebaseRemoteConfig;
import com.google.firebase.remoteconfig.FirebaseRemoteConfigFetchThrottledException;
import com.google.firebase.remoteconfig.FirebaseRemoteConfigValue;
import com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings;
@ -121,7 +122,11 @@ class RNFirebaseRemoteConfig extends ReactContextBaseJavaModule {
if (task.isSuccessful()) {
promise.resolve("remoteConfigFetchStatusSuccess");
} else {
promise.reject("config/failure", task.getException().getMessage(), task.getException());
if (task.getException() instanceof FirebaseRemoteConfigFetchThrottledException) {
promise.reject("config/throttled", "fetch() operation cannot be completed successfully, due to throttling.", task.getException());
} else {
promise.reject("config/failure", "fetch() operation cannot be completed successfully.", task.getException());
}
}
}
});