aboutsummaryrefslogtreecommitdiffstats
path: root/kotlinx-coroutines-core/jvm/test/guide/example-exceptions-05.kt
diff options
context:
space:
mode:
Diffstat (limited to 'kotlinx-coroutines-core/jvm/test/guide/example-exceptions-05.kt')
-rw-r--r--kotlinx-coroutines-core/jvm/test/guide/example-exceptions-05.kt32
1 files changed, 32 insertions, 0 deletions
diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-exceptions-05.kt b/kotlinx-coroutines-core/jvm/test/guide/example-exceptions-05.kt
new file mode 100644
index 00000000..e90606ff
--- /dev/null
+++ b/kotlinx-coroutines-core/jvm/test/guide/example-exceptions-05.kt
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2016-2019 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.guide.exceptions05
+
+import kotlinx.coroutines.exceptions.*
+
+import kotlinx.coroutines.*
+import java.io.*
+
+fun main() = runBlocking {
+ val handler = CoroutineExceptionHandler { _, exception ->
+ println("Caught $exception with suppressed ${exception.suppressed.contentToString()}")
+ }
+ val job = GlobalScope.launch(handler) {
+ launch {
+ try {
+ delay(Long.MAX_VALUE)
+ } finally {
+ throw ArithmeticException()
+ }
+ }
+ launch {
+ delay(100)
+ throw IOException()
+ }
+ delay(Long.MAX_VALUE)
+ }
+ job.join()
+}