https://kotlinlang.org logo
Title
a

aaverin

08/24/2018, 5:43 AM
async and produce ... are relying on the user to consume the final exception
– what if user doesn’t consume final exception, will it be thrown out of async/produce or just quietely hidden?
g

gildor

08/24/2018, 5:56 AM
quietely hidden Someone always should handle Deferred result. Otherwise use launch which do not wrap extensions and just throw them (as threads)
a

aaverin

08/24/2018, 7:29 AM
Still didn’t get it. If I call
myDeferredCourotine.await()
and it throws an exception inside, will I see it?
g

gildor

08/24/2018, 8:08 AM
Yes
await() will throw an exception if code inside of myDeferredCourotine threw it
but only when you call await()
in case of launch code will throw just a global uncaught exception, same as any error in a separate thread and you cannot catch it from outside (cannot wrap launch to try or launchedCoroutine.join(), only code inside of launch)