CancellationException in Kotlin coroutines?CancellationException is a special exception used to indicate that a coroutine was cancelled. It is not treated as a failure but as a normal way to stop coroutine execution.
CancellationException affect coroutine job completion?When a coroutine throws CancellationException, its job is considered cancelled but not failed. This means the coroutine ends normally from the perspective of structured concurrency.
CancellationException usually not be caught and ignored inside coroutines?Because catching and ignoring CancellationException prevents the coroutine from properly cancelling, which can cause resource leaks or unexpected behavior.
CancellationException?Exceptions other than CancellationException are treated as failures, causing the coroutine's job to fail and propagate the error to its parent or handler.
Use try-finally blocks or invokeOnCompletion handlers to run cleanup code. The finally block will run even if CancellationException is thrown.
CancellationException indicate in Kotlin coroutines?CancellationException signals normal cancellation, not failure.
CancellationException, what is the job's state?The job is marked as cancelled, not failed.
CancellationException without rethrowing it?Catching and ignoring CancellationException stops cancellation from propagating.
The finally block always runs for cleanup.
CancellationException?Non-cancellation exceptions cause failure and error propagation.
CancellationException in Kotlin coroutines and how it differs from other exceptions.CancellationException and cleanup in coroutines.