EA-213309: Eliminate "Invalid method id" exception

This commit is contained in:
Yan Zhulanow
2020-01-16 21:13:16 +09:00
parent f6b62f2299
commit 9c889aab17
@@ -68,15 +68,15 @@ fun StackFrameProxy.safeStackFrame(): StackFrame? {
}
fun Location.safeSourceName(): String? {
return wrapAbsentInformationException { this.sourceName() }
return wrapIllegalArgumentException { wrapAbsentInformationException { this.sourceName() } }
}
fun Location.safeSourceName(stratum: String): String? {
return wrapAbsentInformationException { this.sourceName(stratum) }
return wrapIllegalArgumentException { wrapAbsentInformationException { this.sourceName(stratum) } }
}
fun Location.safeLineNumber(): Int {
return DebuggerUtilsEx.getLineNumber(this, false)
return wrapIllegalArgumentException { DebuggerUtilsEx.getLineNumber(this, false) } ?: -1
}
fun Location.safeLineNumber(stratum: String): Int {
@@ -118,6 +118,14 @@ private inline fun <T> wrapEvaluateException(block: () -> T): T? {
}
}
private inline fun <T> wrapIllegalArgumentException(block: () -> T): T? {
return try {
block()
} catch (e: IllegalArgumentException) {
null
}
}
private inline fun <T> wrapAbsentInformationException(block: () -> T): T? {
return try {
block()