Skip to content

[firebase_auth_web] Exceptions returned are incompatible with mobile #2376

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

Closed
buntagonalprism opened this issue Apr 16, 2020 · 2 comments
Closed
Labels
impact: customer A bug with low impact (e.g. affecting only a few customers or has a workaround). (P3) platform: web Issues / PRs which are specifically for web. plugin: auth type: enhancement New feature or request

Comments

@buntagonalprism
Copy link

Issue Summary.
Any exception thrown by firebase_auth_web is a FirebaseError from package:firebase. On mobile a PlatformError is thrown instead. This makes it difficult to have cross-platform error handling logic.

For example, the following logic works great on mobile for handling users attempting to sign in with an unrecognised email address. But to handle errors from web with similar type-safety requires importing the web-only package:firebase to get the FirebaseError class, making it no longer mobile-compatible:

try {
  final user = await auth.signInWithEmailAndPassword(email: email, password: password);
  goToUserHome(user);
} on PlatformException catch (error, trace) {
  if (error.code == "ERROR_USER_NOT_FOUND") {
    showNotFoundWarning();
  } else {
    rethrow;
  }
} 

(The error codes are also different between mobile and web for the same causes, but that's from the underlying Firebase library not FlutterFire).

Desired Solution
firebase_auth_web should map any FirebaseError into a PlatformError to provide API compatability and cross-platform support with the mobile implementation. Or perhaps FirebaseError could be exposed as part of package:firebase_core or similar to avoid the need for a dependency on the web-only package:firebase.

@buntagonalprism buntagonalprism added the type: enhancement New feature or request label Apr 16, 2020
@Ehesp
Copy link
Member

Ehesp commented Apr 22, 2020

Related: #1456

Different platform so leaving open.

@Ehesp Ehesp added impact: customer A bug with low impact (e.g. affecting only a few customers or has a workaround). (P3) plugin: auth labels Apr 22, 2020
@Salakar Salakar added the platform: web Issues / PRs which are specifically for web. label Apr 22, 2020
@Ehesp
Copy link
Member

Ehesp commented Aug 20, 2020

This has been fixed in the latest release.

@Ehesp Ehesp closed this as completed Aug 20, 2020
@firebase firebase locked and limited conversation to collaborators Sep 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
impact: customer A bug with low impact (e.g. affecting only a few customers or has a workaround). (P3) platform: web Issues / PRs which are specifically for web. plugin: auth type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants