fix: BSP error status code in more cases

Ensures that `buildTarget/compile` returns a `StatusCode.Error` instead
of a JSON-RPC error even when the compile error is buried deeper in the
`Incomplete` causes.

Fixes #8104
This commit is contained in:
Alec Theriault 2025-05-07 06:10:34 -04:00
parent 978dd5779d
commit 5d81f2c3d1
No known key found for this signature in database
1 changed files with 12 additions and 4 deletions

View File

@ -789,11 +789,19 @@ object BuildServerProtocol {
Keys.compile.result.value match {
case Value(_) => StatusCode.Success
case Inc(cause) =>
cause.getCause match {
case _: CompileFailed => StatusCode.Error
case _: InterruptedException => StatusCode.Cancelled
case err => throw cause
var statusCodeOpt: Option[Int]
def updateCode(code: Int): Unit =
statusCodeOpt = Some(statusCodeOpt match {
case None => code
case Some(oldCode) => oldCode.max(code)
})
Incomplete.visitAll(cause.getCause) {
case _: CompileFailed => updateCode(StatusCode.Error)
case _: InterruptedException => updateCode(StatusCode.Cancelled)
}
statusCodeOpt.getOrElse(throw cause)
}
}