Distinguish cause attachments from exception attachments in KotlinExceptionWithAttachments

This commit is contained in:
Ilya Kirillov
2022-07-23 17:04:36 +02:00
parent 6f0769ea68
commit edf9e05b13
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.utils
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 @@ open class KotlinExceptionWithAttachments : RuntimeException, ExceptionWithAttac
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())
}
}