Skip to main content

Error Handling for Kotlins

Kotlin coroutine error handling is how failures and cancellation travel through a coroutine hierarchy. Structured concurrency ties child coroutines to a parent scope, so cancelling the parent cancels the children, and an uncaught exception in a child normally cancels siblings unless a SupervisorJob or supervisorScope is used.

Stage: Concurrency · Part of the Kotlin roadmap · Last reviewed 19 November 2026

What to learn in Error Handling

Error Handling interview questions

Why should you never swallow CancellationException?

Cancellation is signalled by throwing CancellationException. If you catch it and carry on, the coroutine ignores the request to stop and may leak work. Rethrow it, or catch narrower exception types, so that structured concurrency can cancel the hierarchy properly.

What does a SupervisorJob change?

With a normal Job, a failing child cancels its parent and therefore its siblings. A SupervisorJob makes failure one way: the child fails alone and siblings keep running. The failed child's exception must then be handled by its own handler or by the caller.

Where Error Handling fits in the Kotlin roadmap

Error Handling belongs to the Concurrency stage (intermediate level), which takes about 16 hours. Coroutines.

Back to the full Kotlin roadmap