diff --git a/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryCustomExceptionsTest.kt b/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryCustomExceptionsTest.kt index dba738a8d3..d4e19040a5 100644 --- a/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryCustomExceptionsTest.kt +++ b/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryCustomExceptionsTest.kt @@ -124,4 +124,22 @@ class StackTraceRecoveryCustomExceptionsTest : TestBase() { assertTrue(ex is CopyableWithCustomMessage) assertEquals("Recovered: [OK]", ex.message) } + + @Test + fun testTryCopyThrows() = runTest { + class FailingException : Exception(), CopyableThrowable { + override fun createCopy(): FailingException? { + TODO("Not yet implemented") + } + } + + val e = FailingException() + val result = runCatching { + coroutineScope { + throw e + } + } + + assertSame(e, result.exceptionOrNull()) + } }