Conclusion
In this lesson, you learned how to handle errors in Kotlin coroutines. You got familiar with SupervisorJobs and CoroutineExceptionHandlers.
The rule of thumb is that the uncaught exception in the child coroutine cancels the parent and all its siblings. This rule isn’t in force when a SupervisorJob is the context of the parent coroutine. Children of such a parent can fail without affecting their parent and other siblings. Take a look at the following cheat sheet:
You can use the CoroutineExceptionHandler to intercept the exceptions that aren’t caught in the coroutines. But you can’t recover from them. You can only use it for diagnostic purposes.
That’s all for this module. See you in the next one!