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

FR: Enum with errors

Open lkostrowski opened this issue 5 years ago • 4 comments

I find useful having this https://firebase.google.com/docs/auth/admin/errors

as an enum exported from typings.

Is this something you are fine with? I can open a PR

lkostrowski avatar Jun 22 '19 12:06 lkostrowski

Error handling in Admin SDKs is about to undergo a major overhaul (this is already in progress with Python and .NET). New error code enum types will be introduced as part of this change. In the meantime, we don't want to introduce any other changes, since almost any change we do at this point will have to be either revised or overwritten as part of the upcoming changes.

hiranya911 avatar Jun 24 '19 21:06 hiranya911

Will this work also change how the grpc errors with integer codes work? I'm relying on code like this right now, and it feels kind of fragile:

      await doc
        .create(data)
        .catch(async err => {
          const { status } = await import('grpc')
          if (err.code === status.ALREADY_EXISTS) {
            return // This is fine.
          }
          throw err
        })

Especially since I firebase-admin doesn't re-export the grpc status codes, so I have to add grpc as a dependency to my own package. And there's nothing that prevents those versions from going out of sync.

iwikal avatar Nov 06 '19 10:11 iwikal

@iwikal that looks like JS code. We haven't figured out how this will look like in JS yet. But chances are good, you will at least be able to compare error codes defined in firebase-admin against the ones thrown by grpc clients.

hiranya911 avatar Nov 06 '19 19:11 hiranya911

Is this related to #403?

naclcaleb avatar Nov 19 '19 19:11 naclcaleb