Conclusion

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

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:

Exceptions in Coroutines Uncaught exceptions go to the parents Unless there is a SupervisorJob Failure in child cancels the parent and other siblings Except for runBlocking Coroutines builders don’t throw exceptions

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!

See forum comments
Download course materials from Github
Previous: Demo Next: Handle Errors