Skip to content

Instantly share code, notes, and snippets.

@GauravChaddha1996
Created January 30, 2021 17:48
Show Gist options
  • Save GauravChaddha1996/20314da0c03d68024a7e3647a5814cbf to your computer and use it in GitHub Desktop.
Save GauravChaddha1996/20314da0c03d68024a7e3647a5814cbf to your computer and use it in GitHub Desktop.
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