Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
val eh = CoroutineExceptionHandler { _, throwable ->
println("Oops error occured: ${throwable.localizedMessage}")
}
launch(eh) {
async {
delay(100)
throw Exception("I failed)
}
withContext(Disptatchers.IO) {
delay(100)
throw Exception("I failed)
}
coroutineScope {
delay(100)
throw Exception("I failed)
}
println(callbackOp())
}
fun callbackOp() = suspendCancellableCoroutine<Int> {
delay(50)
throw Exception("I failed)
}
Output:
(Output for individual run of async, withContext, coroutineScope or
suspendCancellableCoroutine block mentioned above. Shown together for brevity)
Oops error occured: I failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment