mirror of
https://github.com/zhigang1992/react-native-firebase.git
synced 2026-04-24 04:24:52 +08:00
fix(functions): throw UNAVAILABLE code on network IO errors (#3327)
This commit is contained in:
committed by
GitHub
parent
c7a02a1658
commit
73511472bd
@@ -29,6 +29,8 @@ import com.google.firebase.functions.FirebaseFunctionsException;
|
||||
import io.invertase.firebase.common.RCTConvertFirebase;
|
||||
import io.invertase.firebase.common.ReactNativeFirebaseModule;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static io.invertase.firebase.functions.UniversalFirebaseFunctionsModule.CODE_KEY;
|
||||
import static io.invertase.firebase.functions.UniversalFirebaseFunctionsModule.DATA_KEY;
|
||||
import static io.invertase.firebase.functions.UniversalFirebaseFunctionsModule.DETAILS_KEY;
|
||||
@@ -76,6 +78,11 @@ public class ReactNativeFirebaseFunctionsModule extends ReactNativeFirebaseModul
|
||||
details = functionsException.getDetails();
|
||||
code = functionsException.getCode().name();
|
||||
message = functionsException.getMessage();
|
||||
if (functionsException.getCause() instanceof IOException) {
|
||||
// return UNAVAILABLE for network io errors, to match iOS
|
||||
code = FirebaseFunctionsException.Code.UNAVAILABLE.name();
|
||||
message = FirebaseFunctionsException.Code.UNAVAILABLE.name();
|
||||
}
|
||||
}
|
||||
RCTConvertFirebase.mapPutValue(CODE_KEY, code, userInfo);
|
||||
RCTConvertFirebase.mapPutValue(MSG_KEY, message, userInfo);
|
||||
|
||||
Reference in New Issue
Block a user