https://kotlinlang.org logo
Title
s

spierce7

11/14/2018, 5:19 PM
Can anyone explain to me why coroutine exception handling is treated differently between Job and Deferred? Doesn't initially make sense to me why this is desired: https://github.com/Kotlin/kotlinx.coroutines/blob/master/docs/exception-handling.md
v

Vsevolod Tolstopyatov [JB]

11/15/2018, 8:27 AM
what exactly confuses you?
launch
is fire-and-forget computation without a result. If it is failed, no one will ever know about it, so it should be reported somewhere (to exception handler). Meanwhile
async
is not fire-and-forget. It is a computation with result which should be consumed. And if it will be consumed, then exception will be eventually delivered and handled. And if someone called
async
and haven’t called
await
it is probably a bug.
s

spierce7

11/15/2018, 10:04 PM
that makes sense. I just needed someone to explain it. Thanks