Open
Description
Steps to reproduce:
- This snippet prints
null
suspendCancellableCoroutine<Unit> { c ->
c.invokeOnCancellation {
println(it)
}
c.cancel()
}
- Semantically the same snippet prints
CancellationException
:
suspendCancellableCoroutine<Unit> { c ->
c.cancel()
c.invokeOnCancellation {
println(it)
}
}
CompletionHandler
contract:
* The meaning of `cause` that is passed to the handler:
* * Cause is `null` when the job has completed normally.
* * Cause is an instance of [CancellationException] when the job was cancelled _normally_.
* **It should not be treated as an error**. In particular, it should not be reported to error logs.
* * Otherwise, the job had _failed_.