Skip to content

FirebaseAuthPlugin: Error codes are not forwarded to Dart #18312

@escamoteur

Description

@escamoteur

Hi,

I just found out that if an error happens on the FirebaseAuth side like "email already used" I will only get an

      throw new PlatformException(code: errorCode, message: errorMessage, details: errorDetails);

with errorCode = "exception" and an error message that isn't localized which isn't really helpful.

Looking at the Java side of the plugin made it obvious

 private class SignInCompleteListener implements OnCompleteListener<AuthResult> {
    private final Result result;

    SignInCompleteListener(Result result) {
      this.result = result;
    }

    @Override
    public void onComplete(@NonNull Task<AuthResult> task) {
      if (!task.isSuccessful()) {
        Exception e = task.getException();
        result.error(ERROR_REASON_EXCEPTION, e.getMessage(), null);
      } else {
        FirebaseUser user = task.getResult().getUser();
        ImmutableMap<String, Object> userMap = mapFromUser(user);
        result.success(userMap);
      }
    }
  }

This should actually be a [FirebaseAuthException](https://firebase.google.com/docs/reference/android/com/google/firebase/auth/FirebaseAuthException)

which has a `GetErrorCode` method. Please change that so that Apps can react on error conditions with their own texts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    p: firebaseFirebase pluginspackageflutter/packages repository. See also p: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions