mirror of https://github.com/sbt/sbt.git
Improving launcher error handling...
This commit is contained in:
parent
14db8c2079
commit
f186d50daf
|
|
@ -15,16 +15,16 @@ object Boot
|
|||
try { Launch(args.toList) }
|
||||
catch
|
||||
{
|
||||
case b: BootException => errorAndExit(b)
|
||||
case b: BootException => errorAndExit(b.toString)
|
||||
case e =>
|
||||
e.printStackTrace
|
||||
errorAndExit(e)
|
||||
errorAndExit(Pre.prefixError(e.toString))
|
||||
}
|
||||
System.exit(0)
|
||||
}
|
||||
private def errorAndExit(e: Throwable)
|
||||
private def errorAndExit(msg: String)
|
||||
{
|
||||
System.out.println("Error during sbt execution: " + e.toString)
|
||||
System.out.println(msg)
|
||||
System.exit(1)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,12 +10,12 @@ object Initialize
|
|||
{
|
||||
SimpleReader.readLine(promptCreate + " (y/N" + (if(enableQuick) "/s" else "") + ") ") match
|
||||
{
|
||||
case None => error("")
|
||||
case None => declined("")
|
||||
case Some(line) =>
|
||||
line.toLowerCase match
|
||||
{
|
||||
case "y" | "yes" => process(file, spec, _.create)
|
||||
case "n" | "no" | "" => error("")
|
||||
case "n" | "no" | "" => declined("")
|
||||
case "s" => process(file, spec, _.quick)
|
||||
}
|
||||
}
|
||||
|
|
@ -41,7 +41,7 @@ object Initialize
|
|||
{
|
||||
case set: SetProperty => properties.setProperty(name, set.value)
|
||||
case prompt: PromptProperty =>
|
||||
def noValue = error("No value provided for " + prompt.label)
|
||||
def noValue = declined("No value provided for " + prompt.label)
|
||||
SimpleReader.readLine(prompt.label + prompt.default.toList.map(" [" + _ + "]").mkString + ": ") match
|
||||
{
|
||||
case None => noValue
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
package xsbt.boot
|
||||
|
||||
// The exception to use when an error occurs at the launcher level (and not a nested exception).
|
||||
// This indicates overrides toString because the exception class name is not needed to understand
|
||||
// the error message.
|
||||
class BootException(override val toString: String) extends RuntimeException(toString)
|
||||
|
|
@ -100,8 +100,4 @@ object LogLevel extends Enumeration
|
|||
def apply(s: String): Logging = new Logging(toValue(s))
|
||||
}
|
||||
|
||||
final class AppConfiguration(val arguments: Array[String], val baseDirectory: File, val provider: xsbti.AppProvider) extends xsbti.AppConfiguration
|
||||
// The exception to use when an error occurs at the launcher level (and not a nested exception).
|
||||
// This indicates overrides toString because the exception class name is not needed to understand
|
||||
// the error message.
|
||||
class BootException(override val toString: String) extends RuntimeException
|
||||
final class AppConfiguration(val arguments: Array[String], val baseDirectory: File, val provider: xsbti.AppProvider) extends xsbti.AppConfiguration
|
||||
|
|
@ -12,7 +12,9 @@ object Pre
|
|||
def assert(condition: Boolean, msg: => String): Unit = if (!condition) throw new AssertionError(msg)
|
||||
def assert(condition: Boolean): Unit = assert(condition, "Assertion failed")
|
||||
def require(condition: Boolean, msg: => String): Unit = if (!condition) throw new IllegalArgumentException(msg)
|
||||
def error(msg: String): Nothing = throw new BootException(msg)
|
||||
def error(msg: String): Nothing = throw new BootException(prefixError(msg))
|
||||
def declined(msg: String): Nothing = throw new BootException(msg)
|
||||
def prefixError(msg: String): String = "Error during sbt execution: " + msg
|
||||
def toBoolean(s: String) = java.lang.Boolean.parseBoolean(s)
|
||||
def toArray[T](list: List[T]) =
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue