是否可以使用JS SDK访问Firestore错误代码枚举?
我的意思是,类似firebase.firestore.FirestoreErrorCode
的东西
我需要访问它们来翻译我的应用程序错误
您可以看到这里定义的错误-https://github.com/firebase/firebase-js-sdk/blob/master/packages/firestore/src/util/error.ts
看起来FirestoreErrorCode
和FirestoreError
是从包的索引中导出的。
FirestoreErrorCode
是可能的错误代码的并集类型,而FireStoreError
是可丢弃的错误对象。
因为FirestoerErrorCode
被定义为文本字符串的并集,所以不能在代码中直接使用这些字符串。如果它们被定义为枚举,您将能够通过枚举属性访问值。
对于Firebase身份验证,您可以这样访问它们:
import { AuthErrorCodes } from 'firebase/auth';
然后你可以这样使用它:
if (error.code === AuthErrorCodes.USER_DELETED) {
...
}