<lambda>null1// This file was automatically generated from exception-handling.md by Knit tool. Do not edit. 2 package kotlinx.coroutines.guide.exampleExceptions05 3 4 import kotlinx.coroutines.exceptions.* 5 6 import kotlinx.coroutines.* 7 import java.io.* 8 9 @OptIn(DelicateCoroutinesApi::class) 10 fun main() = runBlocking { 11 val handler = CoroutineExceptionHandler { _, exception -> 12 println("CoroutineExceptionHandler got $exception with suppressed ${exception.suppressed.contentToString()}") 13 } 14 val job = GlobalScope.launch(handler) { 15 launch { 16 try { 17 delay(Long.MAX_VALUE) // it gets cancelled when another sibling fails with IOException 18 } finally { 19 throw ArithmeticException() // the second exception 20 } 21 } 22 launch { 23 delay(100) 24 throw IOException() // the first exception 25 } 26 delay(Long.MAX_VALUE) 27 } 28 job.join() 29 } 30