Skip to content

Commit b545807

Browse files
authored
Validate that throwing tryCopy does not crash with an internal error (#3063)
Motivated by #3031
1 parent 83ffd17 commit b545807

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryCustomExceptionsTest.kt

+18
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,22 @@ class StackTraceRecoveryCustomExceptionsTest : TestBase() {
124124
assertTrue(ex is CopyableWithCustomMessage)
125125
assertEquals("Recovered: [OK]", ex.message)
126126
}
127+
128+
@Test
129+
fun testTryCopyThrows() = runTest {
130+
class FailingException : Exception(), CopyableThrowable<FailingException> {
131+
override fun createCopy(): FailingException? {
132+
TODO("Not yet implemented")
133+
}
134+
}
135+
136+
val e = FailingException()
137+
val result = runCatching {
138+
coroutineScope<Unit> {
139+
throw e
140+
}
141+
}
142+
143+
assertSame(e, result.exceptionOrNull())
144+
}
127145
}

0 commit comments

Comments
 (0)