【发布时间】:2025-11-30 20:20:08
【问题描述】:
问题:
我有以下函数显示警告No calls to throwing functions occur within 'try' expression
问题:
- 为什么会显示此警告? (任务里面的代码会报错)
- 我应该怎么做才能将错误传播给
f1的调用者?
代码:
func f1() async throws {
try await withThrowingTaskGroup(of: Int.self) { group in //No calls to throwing functions occur within 'try' expression
group.addTask(priority: .high) {
throw NSError()
}
}
}
【问题讨论】:
标签: ios swift async-await swift-concurrency