Astronaut4449
07/15/2020, 3:30 PMasync
-coroutine-builder of the kotlinx.coroutines library can throw exceptions since the coroutine builder itself does not throw an exception but the .await()
does?
/**
* @throws[IllegalStateException] ... <- would this be correct?
*/
fun CoroutineScope.doStuffAsync() = async { ... }
louiscad
07/15/2020, 3:41 PMasync
and its structured concurrency gotchas?Astronaut4449
07/15/2020, 4:20 PMlouiscad
07/15/2020, 4:21 PMlaunch
might make sense in some cases so long the function handles errors/throwables internally (if any) and doesn't throw which would propagate to the scope.Erik
07/15/2020, 5:00 PMDeferred
that is returned has the await
function, which is documented well enough. However, what it throws might be an impl detail. I'd go for a suspending function that returns the value too.julian
07/15/2020, 5:07 PMlouiscad
07/15/2020, 5:08 PMasync
block cancels the parent CoroutineScope
julian
07/15/2020, 5:09 PM