From f00a145dd74cbb945a8a0c0cdcfa9b2671071a05 Mon Sep 17 00:00:00 2001 From: Vladimir Sukharev Date: Sat, 3 Feb 2024 21:14:16 +0100 Subject: [PATCH] [K/N] Don't cut cinterop exceptions from TC logs. --- .../org/jetbrains/kotlin/native/interop/gen/jvm/main.kt | 5 +++++ .../test/blackbox/support/compilation/CompilationToolCall.kt | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/kotlin-native/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/main.kt b/kotlin-native/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/main.kt index 0b5c068225d..2be26b3d772 100644 --- a/kotlin-native/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/main.kt +++ b/kotlin-native/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/main.kt @@ -85,6 +85,11 @@ class Interop { interop(flavor, args, internalInteropOptions, runFromDaemon) } catch (prettyException: CInteropPrettyException) { prettyException + } catch (throwable: Throwable) { + // Return Throwable to be printed to logs by invoker, instead of allowing unprettified exception to be thrown through reflection invocation, + // which otherwise will be replaced with InvocationTargetException with null error message and huge stacktrace which TeamCity cuts, + // so "Caused by:" part is not saved to the log. + throwable } } diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/compilation/CompilationToolCall.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/compilation/CompilationToolCall.kt index 89ea7c76241..c05730aa239 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/compilation/CompilationToolCall.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/compilation/CompilationToolCall.kt @@ -148,7 +148,7 @@ internal fun invokeCInterop( cinteropResult is Exception -> { CompilationToolCallResult( exitCode = ExitCode.COMPILATION_ERROR, - toolOutput = cinteropResult.message ?: "", + toolOutput = cinteropResult.stackTraceToString(), toolOutputHasErrors = true, duration )