withThrowingTaskGroup

I want to confirm a question.

basically in this method. it allows writing some “try” functions when we want to implement concurrent handling. but if one of the functions throws an error. all of remaining tasks will be cancelled.
also we cant get any result.
The way to avoid it is to use “group.waitForAll”. it will throw an error. but the remaining tasks will still be executed.

My understanding is correct?

then I think maybe “withTaskGroup” + “Result” will be a better way.

Your assumptions are correct - if one of the group tasks throws an error that makes the whole group fail. If you use a non-throwing group and add the error handling code yourself - you can have failing and completing tasks (both options are covered in the book).

These are two different behaviors - it’s up to you to pick which one you’d like to have depending on your requirements.

1 Like

Thank you very much!