This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val eh = CoroutineExceptionHandler { _, throwable -> | |
println("Oops error occured: ${throwable.localizedMessage}") | |
} | |
// Crashes the main thread since top most launch doesn't | |
// handle exception even if child coroutine does | |
launch { | |
delay(100) | |
launch(eh) { | |
throw Exception("I failed") | |
} | |
} | |
// Doesn't crashes the main thread and the exception is caught | |
launch(eh) { | |
delay(100) | |
launch { | |
throw Exception("I failed") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment