From d103f401c401bedb45855afecf7916684cf27462 Mon Sep 17 00:00:00 2001 From: Ryan Sobol Date: Thu, 31 Dec 2020 07:48:55 -0800 Subject: [PATCH] Prepend try to throwing async function calls Since both the `chopVegetables()` and `preheatOven(temperature:)` async functions can throw, does this code example need to prepend a `try` keyword before `await`ing on them? --- proposals/nnnn-structured-concurrency.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proposals/nnnn-structured-concurrency.md b/proposals/nnnn-structured-concurrency.md index 440d58d8dc..855b0a406c 100644 --- a/proposals/nnnn-structured-concurrency.md +++ b/proposals/nnnn-structured-concurrency.md @@ -245,7 +245,7 @@ We can then re-implement `makeDinner` with only a task group: func makeDinnerTaskGroup() async throws -> Meal { withTaskGroup(resultType: DinnerChildTask.self) { group in await group.add { - DinnerChild.chopVegetables(await chopVegetables()) + DinnerChild.chopVegetables(try await chopVegetables()) } await group.add { @@ -253,7 +253,7 @@ func makeDinnerTaskGroup() async throws -> Meal { } await group.add { - DinnerChild.preheatOven(await preheatOven(temperature: 350)) + DinnerChild.preheatOven(try await preheatOven(temperature: 350)) } var veggies: [Vegetable]? = nil