Wondering what would be the idiomatic way to launch multiple coroutines in a
supervisorScope
while still capturing all exceptions (aggregated) that are thrown in them.
Note that I do not want failure of a child to cancel other children (or the scope), hence supervisor scope, but I might want to “sum” (probably
addSuppressed
) all exceptions and throw it later after scope is done
Right now I’m using
withContext
with a custom
CoroutineExceptionHandler
that puts all exceptions in a collection and later reduce the collection and throw, but it just feels boilerplate-y and wonder if I’m missing something
s
Sam
03/16/2023, 1:24 PM
How would you write this if you weren’t using coroutines? Maybe instead of having the child coroutines fail, you could instead have them return something like a