blob: e70443bef4bd025d4d7b955310d0df8e00284864 [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 = launch(handler) {
val inner = launch(coroutineContext) {
launch(coroutineContext) {
launch(coroutineContext) {
throw IOException()
}
}
}
try {
inner.join()
} catch (e: JobCancellationException) {
println("Rethrowing JobCancellationException with original cause")
throw e
}
}
job.join()
}