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

fix: Export error classes #2151

Merged
merged 4 commits into from
May 8, 2024
Merged

Conversation

IchordeDionysos
Copy link
Contributor

@IchordeDionysos IchordeDionysos commented Apr 17, 2023

Discussion

Expose the FirebaseError classes to enable code like this:

catch (e) {
  if (e instanceof FirebaseError) {
    if (e.code === 'auth/' + AuthClientErrorCode.USER_NOT_FOUND.code) {
      throw new UserNotFoundException({email});
    }
  }
  throw e;
}

Testing

  • Make sure all existing tests in the repository pass after your change.
  • If you fixed a bug or added a feature, add a new test to cover your code.

API Changes

  • At this time we cannot accept changes that affect the public API. If you'd like to help
    us make Firebase APIs better, please propose your change in an issue so that we
    can discuss it together.

@jketcham
Copy link

Would love to see this added, it doesn't appear there's another way to easily access the error types from this package?

@Bullfrog1234
Copy link

I agree this is needed and follows the standard JS pattern for checking for a particular error. Error handling is important to good quality code and this library needs to support that also.

@IchordeDionysos this has got out of data with the base branch may need an update

@lahirumaramba lahirumaramba changed the title Expose error classes fix: Export error classes May 8, 2024
@lahirumaramba lahirumaramba self-assigned this May 8, 2024
Copy link
Member

@lahirumaramba lahirumaramba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @IchordeDionysos ! LGTM!

@lahirumaramba lahirumaramba mentioned this pull request May 8, 2024
@lahirumaramba lahirumaramba merged commit bde4308 into firebase:master May 8, 2024
3 of 5 checks passed
@IchordeDionysos IchordeDionysos deleted the patch-1 branch June 11, 2024 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants