[IR] Print exception's class in error message from interpreter
This commit is contained in:
+3
-3
@@ -92,16 +92,16 @@ internal class ExceptionState private constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getShortDescription(): String {
|
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 {
|
fun getFullDescription(): String {
|
||||||
// TODO remainder of the stack trace with "..."
|
// 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 prefix = if (stackTrace.isNotEmpty()) "\n\t" else ""
|
||||||
val postfix = if (stackTrace.size > 10) "\n\t..." else ""
|
val postfix = if (stackTrace.size > 10) "\n\t..." else ""
|
||||||
val causeMessage = cause?.getFullDescription()?.replaceFirst("Exception ", "\nCaused by: ") ?: ""
|
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) +
|
stackTrace.subList(0, min(stackTrace.size, 10)).joinToString(separator = "\n\t", prefix = prefix, postfix = postfix) +
|
||||||
causeMessage
|
causeMessage
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -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
|
||||||
|
|||||||
+2
-2
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user