https://kotlinlang.org logo
e

elizarov

04/20/2017, 7:51 AM
@kirillrakhman In short, yes. The more correct statement is this: When you do
job.cancel
the next cancellable suspending function that you invoke will throw
CancellationException
. All suspending functions in
kotlinx.coroutines
are cancellable and they all mention this behavior in their docs. So,
launch
coroutine builder has a handler for uncaught exception (similarly to uncaught exception in threads) and it does ignore
CancellationException
, so you should too. More on the logic for handling uncaught exceptions in coroutines can be found here: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/handle-coroutine-exception.html