Skip to content

Commit daa5d44

Browse files
authored
More attempts at robustizing BSP (#6056)
1 parent 8aa690a commit daa5d44

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

libs/script/src/ScriptModuleInit.scala

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,8 @@ object ScriptModuleInit
126126
discoverScriptFiles(workspaceRoot, os.Path(mill.constants.OutFiles.out, workspaceRoot))
127127
.filter(p => !nonScriptSourceFolders.exists(p.startsWith(_)))
128128
.flatMap { scriptPath =>
129-
try {
130-
resolveScriptModule(scriptPath.toString, eval.resolveScriptModuleDep).map { result =>
131-
(scriptPath.toNIO, result)
132-
}
133-
} catch {
134-
case e: Exception =>
135-
// If resolving a script module fails, just log it and ignore
136-
// it rather than blowing up the whole BSP import process
137-
println("Failed to instantiate script during BSP import and discovery: " + scriptPath)
138-
println(e)
139-
e.printStackTrace()
140-
None
129+
resolveScriptModule(scriptPath.toString, eval.resolveScriptModuleDep).map { result =>
130+
(scriptPath.toNIO, result)
141131
}
142132
}
143133
}

runner/bsp/worker/src/mill/bsp/worker/BspEvaluators.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,12 @@ private[mill] class BspEvaluators(
8686
.invoke(null, nonScriptSources, eval)
8787
.asInstanceOf[Seq[(java.nio.file.Path, mill.api.Result[BspModuleApi])]]
8888

89-
result.map {
89+
result.flatMap {
9090
case (scriptPath: java.nio.file.Path, mill.api.Result.Success(module: BspModuleApi)) =>
91-
(new BuildTargetIdentifier(Utils.sanitizeUri(scriptPath)), (module, eval))
91+
Some((new BuildTargetIdentifier(Utils.sanitizeUri(scriptPath)), (module, eval)))
92+
case (scriptPath: java.nio.file.Path, mill.api.Result.Failure(msg: String)) =>
93+
println(s"Failed to instantiate script module for BSP: $scriptPath failed with $msg")
94+
None
9295
}
9396
}
9497
lazy val bspModulesById: Map[BuildTargetIdentifier, (BspModuleApi, EvaluatorApi)] = {

0 commit comments

Comments
 (0)