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 composing-suspending-functions.md by Knit tool. Do not edit.
6 package kotlinx.coroutines.guide.exampleCompose06
7 
8 import kotlinx.coroutines.*
9 
<lambda>null10 fun main() = runBlocking<Unit> {
11     try {
12         failedConcurrentSum()
13     } catch(e: ArithmeticException) {
14         println("Computation failed with ArithmeticException")
15     }
16 }
17 
<lambda>null18 suspend fun failedConcurrentSum(): Int = coroutineScope {
19     val one = async<Int> {
20         try {
21             delay(Long.MAX_VALUE) // Emulates very long computation
22             42
23         } finally {
24             println("First child was cancelled")
25         }
26     }
27     val two = async<Int> {
28         println("Second child throws an exception")
29         throw ArithmeticException()
30     }
31     one.await() + two.await()
32 }
33