1 // This file was automatically generated from composing-suspending-functions.md by Knit tool. Do not edit.
2 package kotlinx.coroutines.guide.exampleCompose06
3 
4 import kotlinx.coroutines.*
5 
<lambda>null6 fun main() = runBlocking<Unit> {
7     try {
8         failedConcurrentSum()
9     } catch(e: ArithmeticException) {
10         println("Computation failed with ArithmeticException")
11     }
12 }
13 
<lambda>null14 suspend fun failedConcurrentSum(): Int = coroutineScope {
15     val one = async<Int> {
16         try {
17             delay(Long.MAX_VALUE) // Emulates very long computation
18             42
19         } finally {
20             println("First child was cancelled")
21         }
22     }
23     val two = async<Int> {
24         println("Second child throws an exception")
25         throw ArithmeticException()
26     }
27     one.await() + two.await()
28 }
29