Why exception handling with Kotlin Coroutines is hard and how to master it!
summary
Explains why exception handling with Kotlin Coroutines is more complex than the happy path and what to consider to handle errors correctly. Covers when to use try-catch versus CoroutineExceptionHandler, differences between top-level coroutines started with launch and async, behaviors of coroutineScope{} and supervisorScope{}, and the need to re-throw CancellationException to avoid subtle bugs.
AI-written summary · about
chapters (16)
- 0:00Introduction
- 2:21Why coroutines
- 3:43Exceptions in regular code
- 5:28Coroutine exception problems
- 8:01Task hierarchy and exception propagation
- 10:18Context-based exception handling
- 13:30Try-catch vs handler
- 16:46Cancellation and structured concurrency
- 19:34Error logging without losing control
- 21:03CancellationException handling
- 24:23CancellationException problems
- 25:51Exceptions in ASH and SupervisorScope
- 27:59Scope and SupervisorScope
- 30:27Final recommendations and cheat sheet
- 33:20Exception handling cheat sheet
- 37:21Q&A
related talks
37mCoroutines! Gotta catch 'em all!
39mMistakes you make using Kotlin Coroutines
43mTough Questions About Kotlin Coroutines
44mTesting Kotlin Coroutines
45mAll the Pitfalls of Coroutines
37mPractical Patterns for Kotlin Coroutines in Production
47mKotlin Coroutines
15m5 Common Traps You Can Step Into When Using Coroutines
