Patrick Steiger
03/16/2023, 12:15 AMsupervisorScope 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 somethingSam
03/16/2023, 1:24 PMResult.Patrick Steiger
03/16/2023, 3:49 PMasync to a list and then mapNotNull { runCatching { it.await() }.exceptionOrNull() } is indeed cleaner, then I can return a list of Throwable to join and throw laterkevin.cianfarini
03/16/2023, 8:30 PMrunCatching in coroutines code. It can capture CancellationException and break structured concurrency.
See: https://github.com/Kotlin/kotlinx.coroutines/issues/1814