firebase / firebase/firebase-js-sdk
FR: Access to fireauth.authenum.Error
- Dominant language
- TypeScript
- Stars
- 5.1k
- Forks
- 1k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 37
Description
### [REQUIRED] Describe your environment
* Operating System version: Windows 8.1
* Browser version: Chrome v79
* Firebase SDK version: v7.7.0
* Firebase Product: auth, but it's probably similar to others
### [REQUIRED] Describe the problem
The docs [here](https://firebase.google.com/docs/reference/js/firebase.auth.Error) describes the `Error` and the `AuthError` objects from `firebase.auth`, but they are not actually exported from the library.
#### Steps to reproduce:
- Import the firebase
- Try to find the auth enum error, created here:
https://github.com/firebase/firebase-js-sdk/blob/43fb3ee3a44c026ce1dfd441b1fc7d162227673d/packages/auth/src/error_auth.js#L115-L197
#### Relevant Code:
I'm handling the errors from Firebase Auth with something like this:
```javascript
.catch(err => {
switch (err.code) {
case 'auth/too-many-requests':
...
break;
default:
...
}
})
```
... but it would be better if I got something like this:
```javascript
.catch(err => {
switch (err.code) {
case firebase.auth.AuthError.TOO_MANY_ATTEMPTS_TRY_LATER:
...
break;
default:
...
}
})
```
I know that's much more code, but I don't need care about how the codes are and don't need to keep rereading the docs to see other error codes that can happen, I would just let the autocomplete do it's work. It's more about allow us to use this code design too...
Contributor guide
Assessment
This issue has not been assessed yet.