Skip to content

Instantly share code, notes, and snippets.

@jaozinfs
Created June 7, 2022 19:57
Show Gist options
  • Save jaozinfs/94b509e27b1b79a11a4b3523b68de722 to your computer and use it in GitHub Desktop.
Save jaozinfs/94b509e27b1b79a11a4b3523b68de722 to your computer and use it in GitHub Desktop.
fun main() = runBlocking {
val handler = CoroutineExceptionHandler { _, exception ->
println("CoroutineExceptionHandler hot $exception")
}
val job = launch(handler) {
supervisorScope {
launch {
downloadImage()
println("finish download 1")
}
launch {
downloadSounds()
println("finish download 2")
}
}
println("finish downloads")
}
job.join()
println("Finish Job")
}
suspend fun downloadImage(){
(1..2).onEach {
delay(300)
println("image $it")
}
}
suspend fun downloadSounds() {
(1..2).onEach {
delay(300)
throw Exception("Error on get sound $it")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment