mirror of https://github.com/sbt/sbt.git
Exception.getMessage can be null
This commit is contained in:
parent
3834a9519c
commit
00484df435
|
|
@ -204,7 +204,7 @@ object Cache {
|
|||
-\/(FileError.ConcurrentDownload(url))
|
||||
}
|
||||
catch { case e: Exception =>
|
||||
-\/(FileError.DownloadError(s"Caught $e (${e.getMessage})"))
|
||||
-\/(FileError.DownloadError(s"Caught $e${Option(e.getMessage).fold("")(" (" + _ + ")")}"))
|
||||
}
|
||||
|
||||
private def temporaryFile(file: File): File = {
|
||||
|
|
@ -232,7 +232,7 @@ object Cache {
|
|||
|
||||
def printError(e: Exception): Unit =
|
||||
scala.Console.err.println(
|
||||
s"Cannot instantiate $clsName: $e${Option(e.getMessage).map(" ("+_+")")}"
|
||||
s"Cannot instantiate $clsName: $e${Option(e.getMessage).fold("")(" ("+_+")")}"
|
||||
)
|
||||
|
||||
val handlerOpt = clsOpt.flatMap {
|
||||
|
|
@ -811,18 +811,6 @@ object Cache {
|
|||
buffer.toByteArray
|
||||
}
|
||||
|
||||
def readFully(is: => InputStream) =
|
||||
Task {
|
||||
\/.fromTryCatchNonFatal {
|
||||
val is0 = is
|
||||
val b =
|
||||
try readFullySync(is0)
|
||||
finally is0.close()
|
||||
|
||||
new String(b, "UTF-8")
|
||||
} .leftMap(_.getMessage)
|
||||
}
|
||||
|
||||
def withContent(is: InputStream, f: (Array[Byte], Int) => Unit): Unit = {
|
||||
val data = Array.ofDim[Byte](16384)
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ object CacheParse {
|
|||
repo.success
|
||||
} catch {
|
||||
case e: MalformedURLException =>
|
||||
("Error parsing URL " + url + Option(e.getMessage).map(" (" + _ + ")").mkString).failure
|
||||
("Error parsing URL " + url + Option(e.getMessage).fold("")(" (" + _ + ")")).failure
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,10 +32,10 @@ object Platform {
|
|||
|
||||
new String(b, "UTF-8")
|
||||
} .leftMap{
|
||||
case e: java.io.FileNotFoundException =>
|
||||
case e: java.io.FileNotFoundException if e.getMessage != null =>
|
||||
s"Not found: ${e.getMessage}"
|
||||
case e =>
|
||||
s"$e: ${e.getMessage}"
|
||||
s"$e${Option(e.getMessage).fold("")(" (" + _ + ")")}"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ case class Bootstrap(
|
|||
|
||||
try Files.write(output0.toPath, shellPreamble.getBytes("UTF-8") ++ buffer.toByteArray)
|
||||
catch { case e: IOException =>
|
||||
Console.err.println(s"Error while writing $output0: ${e.getMessage}")
|
||||
Console.err.println(s"Error while writing $output0${Option(e.getMessage).fold("")(" (" + _ + ")")}")
|
||||
sys.exit(1)
|
||||
}
|
||||
|
||||
|
|
@ -218,7 +218,10 @@ case class Bootstrap(
|
|||
case e: UnsupportedOperationException =>
|
||||
// Ignored
|
||||
case e: IOException =>
|
||||
Console.err.println(s"Error while making $output0 executable: ${e.getMessage}")
|
||||
Console.err.println(
|
||||
s"Error while making $output0 executable" +
|
||||
Option(e.getMessage).fold("")(" (" + _ + ")")
|
||||
)
|
||||
sys.exit(1)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ package object compatibility {
|
|||
def xmlParse(s: String): Either[String, Xml.Node] = {
|
||||
def parse =
|
||||
try Right(scala.xml.XML.loadString(s))
|
||||
catch { case e: Exception => Left(e.getMessage) }
|
||||
catch { case e: Exception => Left(e.toString + Option(e.getMessage).fold("")(" (" + _ + ")")) }
|
||||
|
||||
def fromNode(node: scala.xml.Node): Xml.Node =
|
||||
new Xml.Node {
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ object Platform {
|
|||
get(artifact.url)
|
||||
.map(\/-(_))
|
||||
.recover { case e: Exception =>
|
||||
-\/(e.getMessage)
|
||||
-\/(e.toString + Option(e.getMessage).fold("")(" (" + _ + ")"))
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
@ -104,9 +104,10 @@ object Platform {
|
|||
.flatMap(_ => get(artifact.url))
|
||||
.map { s => logger.fetched(artifact.url); \/-(s) }
|
||||
.recover { case e: Exception =>
|
||||
logger.other(artifact.url, e.getMessage)
|
||||
-\/(e.getMessage)
|
||||
}
|
||||
val msg = e.toString + Option(e.getMessage).fold("")(" (" + _ + ")")
|
||||
logger.other(artifact.url, msg)
|
||||
-\/(msg)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ object FromSbt {
|
|||
log.warn(
|
||||
"Error parsing Maven repository base " +
|
||||
root +
|
||||
Option(e.getMessage).map(" (" + _ + ")").mkString +
|
||||
Option(e.getMessage).fold("")(" (" + _ + ")") +
|
||||
", ignoring it"
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue