Is it possible to access Firestore error codes enum with the JS SDK?
I mean, something like firebase.firestore.FirestoreErrorCode
I need to access them in order to translate my app errors
CodePudding user response:
You can see the errors defined here - https://github.com/firebase/firebase-js-sdk/blob/master/packages/firestore/src/util/error.ts
It looks like FirestoreErrorCode
and FirestoreError
are exported from the index of the package.
FirestoreErrorCode
is an union type of the possible error codes while FireStoreError
is a throwable Error object.
Because FirestoerErrorCode
is defined as a union of literal strings you can't use those strings directly in your code. If they were defined an enum you would be able to access values through the enum properties.