Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIREBASE_AUTH] Consider strongly typing exceptions and/or returning results with errors #2653

Closed
matthew-carroll opened this issue May 28, 2020 · 2 comments
Labels
blocked: customer-response Waiting for customer response, e.g. more information was requested. plugin: auth resolution: needs-repro This issue could not be reproduced or needs an up to date reproduction on latest FlutterFire plugin. type: enhancement New feature or request

Comments

@matthew-carroll
Copy link

I'm working with email/password authentication. I see that this process can fail for a number of reasons, and those failures are expressed as PlatformExceptions with code Strings.

This is cumbersome for multiple reasons:

  • Authentication is expected to have many possible failure cases. Treating these cases as "errors" or "exceptions" that need to be try/catch'ed is, in my opinion, an unnecessary hassle. An AuthResult is already being returned. Why not use that object to represent failures, too?
  • Representing the failure reason as a String makes it easy to introduce typos when handling failures. It also requires that each app project create an enum for this purpose, or re-type the String representation in multiple places.

At a minimum, I would recommend strongly typing all error cases instead of using Strings. But I would also recommend considering a request/response paradigm that doesn't treat common cases, like a bad password, as a language-level error.

@Ehesp
Copy link
Member

Ehesp commented May 28, 2020

This is planned as part of #2582

@TahaTesser TahaTesser added plugin: auth type: enhancement New feature or request labels May 28, 2020
@Salakar Salakar added blocked: customer-response Waiting for customer response, e.g. more information was requested. resolution: needs-repro This issue could not be reproduced or needs an up to date reproduction on latest FlutterFire plugin. labels Aug 25, 2020
@Ehesp
Copy link
Member

Ehesp commented Aug 25, 2020

This is now handled in the rework, please see https://firebase.flutter.dev/docs/auth/error-handling for more information

@Ehesp Ehesp closed this as completed Aug 25, 2020
@firebase firebase locked and limited conversation to collaborators Sep 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
blocked: customer-response Waiting for customer response, e.g. more information was requested. plugin: auth resolution: needs-repro This issue could not be reproduced or needs an up to date reproduction on latest FlutterFire plugin. type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants