[IR] Print exception's class in error message from interpreter

This commit is contained in:
Ivan Kylchik
2023-09-12 18:19:16 +02:00
committed by Space Team
parent 2df5b48474
commit ede6eb0b34
3 changed files with 8 additions and 8 deletions
@@ -92,16 +92,16 @@ internal class ExceptionState private constructor(
}
fun getShortDescription(): String {
return message.let { if (it?.isNotEmpty() == true) it else "???" }
val message = message.let { if (it?.isNotEmpty() == true) ": $it" else "" }
return "Exception $exceptionFqName$message"
}
fun getFullDescription(): String {
// TODO remainder of the stack trace with "..."
val message = message.let { if (it?.isNotEmpty() == true) ": $it" else "" }
val prefix = if (stackTrace.isNotEmpty()) "\n\t" else ""
val postfix = if (stackTrace.size > 10) "\n\t..." else ""
val causeMessage = cause?.getFullDescription()?.replaceFirst("Exception ", "\nCaused by: ") ?: ""
return "Exception $exceptionFqName$message" +
return getShortDescription() +
stackTrace.subList(0, min(stackTrace.size, 10)).joinToString(separator = "\n\t", prefix = prefix, postfix = postfix) +
causeMessage
}
@@ -1,5 +1,5 @@
/exceptionFromInterpreter.kt:(197,200): error: Cannot evaluate constant expression: / by zero
/exceptionFromInterpreter.kt:(197,200): error: Cannot evaluate constant expression: Exception java.lang.ArithmeticException: / by zero
/exceptionFromInterpreter.kt:(239,254): error: Cannot evaluate constant expression: marginPrefix must be non-blank string.
/exceptionFromInterpreter.kt:(239,254): error: Cannot evaluate constant expression: Exception java.lang.IllegalArgumentException: marginPrefix must be non-blank string.
/exceptionFromInterpreter.kt:(305,308): error: Cannot evaluate constant expression: / by zero
/exceptionFromInterpreter.kt:(305,308): error: Cannot evaluate constant expression: Exception java.lang.ArithmeticException: / by zero
@@ -1,3 +1,3 @@
/recursionAccess.kt:(180,194): error: Cannot evaluate constant expression: ???
/recursionAccess.kt:(180,194): error: Cannot evaluate constant expression: Exception java.lang.StackOverflowError
/recursionAccess.kt:(280,283): error: Cannot evaluate constant expression: ???
/recursionAccess.kt:(280,283): error: Cannot evaluate constant expression: Exception java.lang.NullPointerException