1 /*
2  * 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.exampleSupervision02
7 
8 import kotlin.coroutines.*
9 import kotlinx.coroutines.*
10 
<lambda>null11 fun main() = runBlocking {
12     try {
13         supervisorScope {
14             val child = launch {
15                 try {
16                     println("The child is sleeping")
17                     delay(Long.MAX_VALUE)
18                 } finally {
19                     println("The child is cancelled")
20                 }
21             }
22             // Give our child a chance to execute and print using yield
23             yield()
24             println("Throwing an exception from the scope")
25             throw AssertionError()
26         }
27     } catch(e: AssertionError) {
28         println("Caught an assertion error")
29     }
30 }
31