[英]List of Firestore Error Codes for Flutter
When using Cloud Firestore in my Flutter application I want to use the error codes to return a localized error message to the user.在我的 Flutter 应用程序中使用 Cloud Firestore 时,我想使用错误代码向用户返回本地化错误消息。 However, I did not find a list of all the possible error codes that could occur.
但是,我没有找到所有可能发生的错误代码的列表。 Is there a list like that or do I have to handle the errors differently?
是否有这样的列表,或者我必须以不同的方式处理错误?
You can see the list of possible exception codes at the gRPC or at the documentation .您可以在gRPC或文档中查看可能的异常代码列表。 But, you need to change the code from uppercase to all lowercase and replace
underscore
with dash
.但是,您需要将代码从大写更改为全部小写,并将
underscore
替换为dash
。 For example: PERMISSION_DENIED
-> permission-denied
例如:
PERMISSION_DENIED
-> permission-denied
NOT_FOUND
-> not-found
NOT_FOUND
-> not-found
And so on.等等。 Also, you need to catch
FirebaseException
instead of PlatformException
in the new version of cloud_firestore
.此外,您需要在新版本的
cloud_firestore
中捕获FirebaseException
而不是PlatformException
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.