[android] added additional logic to authExceptionToMap to try and cast exceptions to FirebaseAuthException. Sometimes this is unable to cast hence the previous version of this function, now tries both.
This commit is contained in:
parent
1acbff834f
commit
e54fb2a4bc
|
@ -706,10 +706,15 @@ public class RNFirebaseAuth extends ReactContextBaseJavaModule {
|
|||
WritableMap error = Arguments.createMap();
|
||||
String code = "UNKNOWN";
|
||||
String message = exception.getMessage();
|
||||
Matcher matcher = Pattern.compile("\\[(.*?)\\]").matcher(message);
|
||||
|
||||
try {
|
||||
FirebaseAuthException authException = (FirebaseAuthException) exception;
|
||||
code = authException.getErrorCode();
|
||||
message = authException.getMessage();
|
||||
} catch (Exception e) {
|
||||
Matcher matcher = Pattern.compile("\\[(.*?)\\]").matcher(message);
|
||||
if (matcher.find()) {
|
||||
code = matcher.group().substring(2, matcher.group().length() - 2);
|
||||
code = matcher.group().substring(2, matcher.group().length() - 2).trim();
|
||||
switch (code) {
|
||||
case "INVALID_CUSTOM_TOKEN":
|
||||
message = "The custom token format is incorrect. Please check the documentation.";
|
||||
|
@ -759,12 +764,11 @@ public class RNFirebaseAuth extends ReactContextBaseJavaModule {
|
|||
case "OPERATION_NOT_ALLOWED":
|
||||
message = "This operation is not allowed. You must enable this service in the console.";
|
||||
break;
|
||||
case "FOO":
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
error.putString("code", "auth/" + code.toLowerCase());
|
||||
error.putString("code", "auth/" + code.toLowerCase().replace("error_", "").replace('_', '-'));
|
||||
error.putString("message", message);
|
||||
return error;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue