mirror of https://github.com/sbt/sbt.git
refactor printing error to an in-function function
This commit is contained in:
parent
5874ad920e
commit
9f9b08edbd
|
|
@ -141,13 +141,17 @@ private[sbt] object xMain {
|
||||||
|
|
||||||
private def getSocketOrExit(
|
private def getSocketOrExit(
|
||||||
configuration: xsbti.AppConfiguration
|
configuration: xsbti.AppConfiguration
|
||||||
): (Option[BootServerSocket], Option[Exit]) =
|
): (Option[BootServerSocket], Option[Exit]) = {
|
||||||
try (Some(new BootServerSocket(configuration)) -> None)
|
def printThrowable(e: Throwable): Unit = {
|
||||||
|
println("sbt thinks that server is already booting because of this exception:")
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
|
||||||
|
try Some(new BootServerSocket(configuration)) -> None
|
||||||
catch {
|
catch {
|
||||||
case e: ServerAlreadyBootingException
|
case e: ServerAlreadyBootingException
|
||||||
if System.console != null && !ITerminal.startedByRemoteClient =>
|
if System.console != null && !ITerminal.startedByRemoteClient =>
|
||||||
println("sbt thinks that server is already booting because of this exception:")
|
printThrowable(e)
|
||||||
e.printStackTrace()
|
|
||||||
println("Create a new server? y/n (default y)")
|
println("Create a new server? y/n (default y)")
|
||||||
val exit =
|
val exit =
|
||||||
if (ITerminal.get.withRawInput(System.in.read) == 'n'.toInt) Some(Exit(1))
|
if (ITerminal.get.withRawInput(System.in.read) == 'n'.toInt) Some(Exit(1))
|
||||||
|
|
@ -156,12 +160,12 @@ private[sbt] object xMain {
|
||||||
case e: ServerAlreadyBootingException =>
|
case e: ServerAlreadyBootingException =>
|
||||||
if (SysProp.forceServerStart) (None, None)
|
if (SysProp.forceServerStart) (None, None)
|
||||||
else {
|
else {
|
||||||
println("Boot server failed to create socket")
|
printThrowable(e)
|
||||||
e.printStackTrace()
|
|
||||||
(None, Some(Exit(2)))
|
(None, Some(Exit(2)))
|
||||||
}
|
}
|
||||||
case _: UnsatisfiedLinkError => (None, None)
|
case _: UnsatisfiedLinkError => (None, None)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final class ScriptMain extends xsbti.AppMain {
|
final class ScriptMain extends xsbti.AppMain {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue