Mar 12, 2023
There is another limitation you didn't mention: sometimes you just want to silently cancel a coroutine manually from the coroutine itself by throwing a CancellationException explicitly. In that case, ensureActive won't throw but you still want to rethrow the exception manually.
But I guess for that case, you recommend calling coroutineContext.cancel() instead of throwing a CancellationException manually ?