Give an explanation in case of ServerAlreadyBootingException (#6353)

Give and explanation in case of ServerAlreadyBootingException
This commit is contained in:
Ondra Pelech 2021-03-05 05:21:42 +01:00 committed by GitHub
parent 5f24664c0d
commit 81457e60ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 4 deletions

View File

@ -345,7 +345,7 @@ public class BootServerSocket implements AutoCloseable {
: new UnixDomainServerSocket(name, jni);
return socket;
} catch (final IOException e) {
throw new ServerAlreadyBootingException();
throw new ServerAlreadyBootingException(e);
}
}

View File

@ -7,4 +7,11 @@
package sbt.internal;
public class ServerAlreadyBootingException extends Exception {}
import java.io.IOException;
public class ServerAlreadyBootingException extends Exception {
public ServerAlreadyBootingException(IOException e) {
super(e);
}
}

View File

@ -118,9 +118,11 @@ private[sbt] object xMain {
): (Option[BootServerSocket], Option[Exit]) =
try (Some(new BootServerSocket(configuration)) -> None)
catch {
case _: ServerAlreadyBootingException
case e: ServerAlreadyBootingException
if System.console != null && !ITerminal.startedByRemoteClient =>
println("sbt server is already booting. Create a new server? y/n (default y)")
println(
s"sbt thinks that server is already booting because of this exception:\n${e.getCause}\nCreate a new server? y/n (default y)"
)
val exit = ITerminal.get.withRawInput(System.in.read) match {
case 110 => Some(Exit(1))
case _ => None