firebase-admin-node icon indicating copy to clipboard operation
firebase-admin-node copied to clipboard

Expose error classes

Open IchordeDionysos opened this issue 2 years ago • 2 comments

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.

IchordeDionysos avatar Apr 17 '23 08:04 IchordeDionysos

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

jketcham avatar Jul 19 '23 03:07 jketcham

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

Bullfrog1234 avatar Nov 02 '23 02:11 Bullfrog1234