From 54743d945d6fbc1a76550efe792386e225f5d5e6 Mon Sep 17 00:00:00 2001 From: Elliot Hesp Date: Thu, 12 Jul 2018 13:28:58 +0100 Subject: [PATCH] [config][android] Explicitly handle task exception --- .../invertase/firebase/config/RNFirebaseRemoteConfig.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/io/invertase/firebase/config/RNFirebaseRemoteConfig.java b/android/src/main/java/io/invertase/firebase/config/RNFirebaseRemoteConfig.java index c2b4acd6..c9cc6bf4 100644 --- a/android/src/main/java/io/invertase/firebase/config/RNFirebaseRemoteConfig.java +++ b/android/src/main/java/io/invertase/firebase/config/RNFirebaseRemoteConfig.java @@ -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()); + } } } });