gpt4 book ai didi

firebase - Flutter firebase - 无法捕获异常抛出的白色尝试使用带有空键的 map 更新文档

转载 作者:行者123 更新时间:2023-12-05 07:21:21 25 4
gpt4 key购买 nike

在尝试使用带有空键的 map 更新 Firestore 中的文档时(我的代码中的错误),我无法捕获异常,这导致了应用程序崩溃。

这是一个示例代码:

try {
Map<String, dynamic> crash = {"": 3}; // this is an empty key (bug)
await docRef.collection('collection').document('doc').updateData({"ABC": crash});
} catch (err) {
print(err);
}

异常(相当合理):

*** Assertion failure in auto firebase::firestore::model::FieldPath::FromServerFormat(const absl::string_view)::(anonymous class)::operator()() const(), /project/ios/Pods/FirebaseFirestore/Firestore/core/src/firebase/firestore/model/field_path.cc:90
Lost connection to device.
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'FIRESTORE INTERNAL ASSERTION FAILED: Invalid field path (s3SEDn5nhnWiqeZjpDmY.``). Paths must not be empty, begin with '.', end with '.', or contain '..' (expected !segment.empty())'

我没有看到错误打印到控制台,也没有看到那里设置的断点。

我的问题/问题:

  1. 我是否以错误的方式使用了 try catch block ?为什么 catch 语句不起作用?

  2. 应用崩溃后,尝试重新启动失败,并出现以下错误:

FileSystemException: Getting current working directory failed, path = '' (OS Error: Too many open files in system, errno = 23)

只有卸载并重新安装该应用程序才有效。知道这是否正常吗?如果没有,我该怎么办?

在 iOS 和 Android 上都崩溃,Firestore 插件版本 cloud_firestore: ^0.12.7

最佳答案

我在尝试使用没有互联网连接(模拟器)的 map 捕获 updateData 上的异常时遇到了类似的问题。

    await Firestore.instance.collection('collection').document(doc).updateDataa({"ABC": crash}).timeout(Duration(seconds: 10));

这是我处理超时并返回连接错误的唯一方法!

关于firebase - Flutter firebase - 无法捕获异常抛出的白色尝试使用带有空键的 map 更新文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56942281/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com