From 0b871d7534a9c8e90fb9ad61cd5345716448d08c Mon Sep 17 00:00:00 2001 From: Ilya Goncharov Date: Fri, 10 Dec 2021 13:39:28 +0300 Subject: [PATCH] [IR] Be ready if message of CompilationException throw exception --- .../backend/common/CompilationException.kt | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/CompilationException.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/CompilationException.kt index bbdcf0807a3..fcfc90c538f 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/CompilationException.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/CompilationException.kt @@ -22,11 +22,17 @@ class CompilationException( cause: Throwable? = null ) : RuntimeException(message, cause) { override val message: String - get() = buildString { - appendLine("Back-end: Please report this problem https://kotl.in/issue") - path?.let { appendLine("$it:$line:$column") } - content?.let { appendLine("Problem with `$it`") } - append("Details: " + super.message) + get() = try { + buildString { + appendLine("Back-end: Please report this problem https://kotl.in/issue") + path?.let { appendLine("$it:$line:$column") } + content?.let { appendLine("Problem with `$it`") } + append("Details: " + super.message) + } + } catch (e: Throwable) { + throw IllegalStateException("Problem with constructing exception message").also { + it.stackTrace = stackTrace + } } val line: Int