blob: 6d95e3f1e4f16872bf504ed8cf11d442c37e5a7a [file] [log] [blame]
/*
* Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit.
package kotlinx.coroutines.experimental.guide.exceptions06
import kotlinx.coroutines.experimental.*
import kotlin.coroutines.experimental.*
import java.io.*
fun main(args: Array<String>) = runBlocking {
val handler = CoroutineExceptionHandler { _, exception ->
println("Caught original $exception")
}
val job = GlobalScope.launch(handler) {
val inner = launch {
launch {
launch {
throw IOException()
}
}
}
try {
inner.join()
} catch (e: JobCancellationException) {
println("Rethrowing JobCancellationException with original cause")
throw e
}
}
job.join()
}