Created
January 30, 2021 17:48
-
-
Save GauravChaddha1996/20314da0c03d68024a7e3647a5814cbf to your computer and use it in GitHub Desktop.
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}") | |
} | |
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