Skip to content

Commit 0592af4

Browse files
authored
Merge pull request #1916 from lwronski/nailgun-server-fail
Suggest users to clean working directory when Nailgun server failed
2 parents d5f89a9 + b5f6a20 commit 0592af4

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

modules/bloop-rifle/src/main/scala/scala/build/blooprifle/BloopRifleLogger.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ trait BloopRifleLogger { self =>
99
def debug(msg: => String, ex: Throwable): Unit
1010
final def debug(msg: => String): Unit = debug(msg, null)
1111
def error(msg: => String, ex: Throwable): Unit
12+
def error(msg: => String): Unit
1213
def runnable(name: String)(r: Runnable): Runnable = { () =>
1314
try r.run()
1415
catch {
@@ -39,6 +40,7 @@ object BloopRifleLogger {
3940
def info(msg: => String) = {}
4041
def debug(msg: => String, ex: Throwable) = {}
4142
def error(msg: => String, ex: Throwable) = {}
43+
def error(msg: => String) = {}
4244
def bloopBspStdout = None
4345
def bloopBspStderr = None
4446
def bloopCliInheritStdout = false

modules/bloop-rifle/src/main/scala/scala/build/blooprifle/internal/Operations.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ object Operations {
339339
}
340340
val runnable: Runnable = logger.runnable(threadName) { () =>
341341
val maybeRetCode = Try {
342-
nailgunClient0.run(
342+
val retCode = nailgunClient0.run(
343343
"bsp",
344344
protocolArgs,
345345
workingDir,
@@ -349,6 +349,12 @@ object Operations {
349349
stop0,
350350
interactiveSession = false
351351
)
352+
if (retCode != 0)
353+
logger.error(
354+
s"""Bloop 'bsp' command exited with code $retCode. Something may be wrong with the current configuration.
355+
|Running the ${Console.BOLD}clean${Console.RESET} sub-command to clear the working directory and remove caches might help.
356+
|If the error persists, please report the issue as a bug and attach a log with increased verbosity by passing ${Console.BOLD}-v -v -v${Console.RESET}.""".stripMargin)
357+
retCode
352358
}
353359
try promise.complete(maybeRetCode)
354360
catch { case _: IllegalStateException => }

modules/build/src/test/scala/scala/build/tests/TestLogger.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ case class TestLogger(info: Boolean = true, debug: Boolean = false) extends Logg
6060
System.err.println(msg)
6161
if (ex != null) ex.printStackTrace(System.err)
6262
}
63+
def error(msg: => String): Unit = System.err.println(msg)
6364
def info(msg: => String): Unit =
6465
System.err.println(msg)
6566
}

modules/cli/src/main/scala/scala/cli/internal/CliLogger.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,11 @@ class CliLogger(
164164
ex.printStackTrace(out)
165165
}
166166
def error(msg: => String, ex: Throwable) = {
167-
logger.log(s"Error: $msg ($ex)")
167+
logger.error(s"Error: $msg ($ex)")
168168
if (verbosity >= 1 && ex != null)
169169
ex.printStackTrace(out)
170170
}
171+
def error(msg: => String) = logger.error(msg)
171172
def bloopBspStdout =
172173
if (verbosity >= 2) Some(out)
173174
else None

0 commit comments

Comments
 (0)