1 /*
<lambda>null2  * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3  */
4 
5 // This file was automatically generated from exception-handling.md by Knit tool. Do not edit.
6 package kotlinx.coroutines.guide.exampleExceptions05
7 
8 import kotlinx.coroutines.exceptions.*
9 
10 import kotlinx.coroutines.*
11 import java.io.*
12 
13 fun main() = runBlocking {
14     val handler = CoroutineExceptionHandler { _, exception ->
15         println("CoroutineExceptionHandler got $exception with suppressed ${exception.suppressed.contentToString()}")
16     }
17     val job = GlobalScope.launch(handler) {
18         launch {
19             try {
20                 delay(Long.MAX_VALUE) // it gets cancelled when another sibling fails with IOException
21             } finally {
22                 throw ArithmeticException() // the second exception
23             }
24         }
25         launch {
26             delay(100)
27             throw IOException() // the first exception
28         }
29         delay(Long.MAX_VALUE)
30     }
31     job.join()
32 }
33