https://kotlinlang.org logo
#coroutines
Title
# coroutines
a

Antoine Gagnon

03/31/2020, 7:06 PM
I’m having some trouble on how to design something with coroutines: I want to do multiple tasks in parallel, but if one of them throws I want to stop all the other ones (putting them in the same coroutineScope seems to do that properly) but I also want to be able to catch any error thrown by the coroutine in the function that launched them (this part is the one I’m struggling with)
s

streetsofboston

03/31/2020, 7:09 PM
a

Antoine Gagnon

03/31/2020, 7:14 PM
Thank you! Seems like the solutions might be to use async or a supervisorJob!
e

elizarov

04/01/2020, 8:29 AM
Just put
try { ... } catch
around the
coroutineScope { ... }
that launches all your coroutines.
👍 1
2 Views