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

Export error codes from Auth #5178

Closed
Feiyang1 opened this issue Jul 20, 2021 · 0 comments · Fixed by #5182
Closed

Export error codes from Auth #5178

Feiyang1 opened this issue Jul 20, 2021 · 0 comments · Fixed by #5182
Assignees

Comments

@Feiyang1
Copy link
Member

Feiyang1 commented Jul 20, 2021

Export error codes as an object map from Auth to make error code check easier. Addresses #4551
To enable use case like the following:

// ErrorCodes is a map of all possible Auth error codes
import { signInAnonymously, ErrorCodes } from 'firebase/auth';

async function signIn() {
    try {
    const credential = signInAnonymously(auth);
  } catch (e) {
    // instead of e.code === 'auth/network-request-failed'
    if (e.code === ErrorCodes.NetworkRequestFailed) {
      // do stuff
    }
  }
}

Object maps are tree shakable, so they incur no size cost if they are not imported.

We may want to do the same in other SDKs as well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants