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.exampleExceptions02
7 
8 import kotlinx.coroutines.*
9 
10 fun main() = runBlocking {
11     val handler = CoroutineExceptionHandler { _, exception ->
12         println("CoroutineExceptionHandler got $exception")
13     }
14     val job = GlobalScope.launch(handler) { // root coroutine, running in GlobalScope
15         throw AssertionError()
16     }
17     val deferred = GlobalScope.async(handler) { // also root, but async instead of launch
18         throw ArithmeticException() // Nothing will be printed, relying on user to call deferred.await()
19     }
20     joinAll(job, deferred)
21 }
22