firebase-admin-node
firebase-admin-node copied to clipboard
FR: Enum with errors
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
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.
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 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.
Is this related to #403?