Distinguish cause attachments from exception attachments in KotlinExceptionWithAttachments
diff --git a/compiler/util/src/org/jetbrains/kotlin/utils/KotlinExceptionWithAttachments.kt b/compiler/util/src/org/jetbrains/kotlin/utils/KotlinExceptionWithAttachments.kt
index f6d9a4f..d903d9e 100644
--- a/compiler/util/src/org/jetbrains/kotlin/utils/KotlinExceptionWithAttachments.kt
+++ b/compiler/util/src/org/jetbrains/kotlin/utils/KotlinExceptionWithAttachments.kt
@@ -7,6 +7,7 @@
import com.intellij.openapi.diagnostic.Attachment
import com.intellij.openapi.diagnostic.ExceptionWithAttachments
+import java.nio.charset.StandardCharsets
import kotlin.contracts.ExperimentalContracts
import kotlin.contracts.contract
@@ -17,7 +18,15 @@
constructor(message: String?, cause: Throwable?) : super(message, cause) {
if (cause is KotlinExceptionWithAttachments) {
- attachments.addAll(cause.attachments)
+ attachments.addAll(
+ cause.attachments.map { a ->
+ val content = a.openContentStream().use { it.reader(StandardCharsets.UTF_8).use { it.readText() } }
+ Attachment("case_" + a.path, content)
+ }
+ )
+ }
+ if (cause != null) {
+ withAttachment("causeThrowable", cause.stackTraceToString())
}
}