Kotlin Tutorial #18: Coroutines Deep Dive — Error Handling, SupervisorJob, and Channels
In the previous tutorial, you learned the basics of coroutines: suspend functions, launch, async, and structured concurrency. Now let’s dive deeper into error handling, supervisor jobs, and channels. In this tutorial, you will learn: CoroutineExceptionHandler SupervisorJob and supervisorScope Channels (send, receive, close) Channel types (buffered, conflated, unlimited) produce and consumeEach Fan-out and fan-in patterns select expression Mutex for shared mutable state withTimeout and withTimeoutOrNull Practical patterns Error Handling in Coroutines Error handling in coroutines is different from regular code. When a coroutine throws an exception, the behavior depends on whether you use launch or async. ...