mirror of https://github.com/sbt/sbt.git
Remove some fatal exception catching
This commit is contained in:
parent
387674a451
commit
32760bed55
|
|
@ -4,6 +4,7 @@
|
||||||
package sbt
|
package sbt
|
||||||
|
|
||||||
import scala.annotation.tailrec
|
import scala.annotation.tailrec
|
||||||
|
import scala.util.control.NonFatal
|
||||||
import java.io.{ File, PrintWriter }
|
import java.io.{ File, PrintWriter }
|
||||||
import jline.TerminalFactory
|
import jline.TerminalFactory
|
||||||
|
|
||||||
|
|
@ -52,7 +53,7 @@ object MainLoop {
|
||||||
case e: xsbti.FullReload =>
|
case e: xsbti.FullReload =>
|
||||||
deleteLastLog(logBacking)
|
deleteLastLog(logBacking)
|
||||||
throw e // pass along a reboot request
|
throw e // pass along a reboot request
|
||||||
case e: Throwable =>
|
case NonFatal(e) =>
|
||||||
System.err.println("sbt appears to be exiting abnormally.\n The log file for this session is at " + logBacking.file)
|
System.err.println("sbt appears to be exiting abnormally.\n The log file for this session is at " + logBacking.file)
|
||||||
deleteLastLog(logBacking)
|
deleteLastLog(logBacking)
|
||||||
throw e
|
throw e
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ package xsbt
|
||||||
import java.io.{ BufferedReader, BufferedWriter, InputStream, InputStreamReader, OutputStreamWriter, OutputStream }
|
import java.io.{ BufferedReader, BufferedWriter, InputStream, InputStreamReader, OutputStreamWriter, OutputStream }
|
||||||
import java.net.{ InetAddress, ServerSocket, Socket }
|
import java.net.{ InetAddress, ServerSocket, Socket }
|
||||||
|
|
||||||
|
import scala.util.control.NonFatal
|
||||||
|
|
||||||
object IPC {
|
object IPC {
|
||||||
private val portMin = 1025
|
private val portMin = 1025
|
||||||
private val portMax = 65536
|
private val portMax = 65536
|
||||||
|
|
@ -28,7 +30,7 @@ object IPC {
|
||||||
def createServer(attempts: Int): ServerSocket =
|
def createServer(attempts: Int): ServerSocket =
|
||||||
if (attempts > 0)
|
if (attempts > 0)
|
||||||
try { new ServerSocket(nextPort, 1, loopback) }
|
try { new ServerSocket(nextPort, 1, loopback) }
|
||||||
catch { case _: Exception => createServer(attempts - 1) }
|
catch { case NonFatal(e) => createServer(attempts - 1) }
|
||||||
else
|
else
|
||||||
sys.error("Could not connect to socket: maximum attempts exceeded")
|
sys.error("Could not connect to socket: maximum attempts exceeded")
|
||||||
createServer(10)
|
createServer(10)
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,9 @@ import sbt.internal.util.{ ~>, AttributeKey, IMap, RMap }
|
||||||
import sbt.internal.util.Types._
|
import sbt.internal.util.Types._
|
||||||
|
|
||||||
import java.io.{ InputStream, OutputStream }
|
import java.io.{ InputStream, OutputStream }
|
||||||
|
|
||||||
|
import scala.util.control.NonFatal
|
||||||
|
|
||||||
import sbinary.{ DefaultProtocol, Format }
|
import sbinary.{ DefaultProtocol, Format }
|
||||||
import DefaultProtocol.{ StringFormat, withStamp }
|
import DefaultProtocol.{ StringFormat, withStamp }
|
||||||
|
|
||||||
|
|
@ -76,11 +79,11 @@ object Previous {
|
||||||
|
|
||||||
private def read[T](stream: InputStream, format: Format[T]): Option[T] =
|
private def read[T](stream: InputStream, format: Format[T]): Option[T] =
|
||||||
try Some(format.reads(stream))
|
try Some(format.reads(stream))
|
||||||
catch { case e: Exception => None }
|
catch { case NonFatal(e) => None }
|
||||||
|
|
||||||
private def write[T](stream: OutputStream, format: Format[T], value: T): Unit =
|
private def write[T](stream: OutputStream, format: Format[T], value: T): Unit =
|
||||||
try format.writes(stream, value)
|
try format.writes(stream, value)
|
||||||
catch { case e: Exception => () }
|
catch { case NonFatal(e) => () }
|
||||||
|
|
||||||
/** Public as a macro implementation detail. Do not call directly. */
|
/** Public as a macro implementation detail. Do not call directly. */
|
||||||
def runtime[T](skey: TaskKey[T])(implicit format: Format[T]): Initialize[Task[Option[T]]] =
|
def runtime[T](skey: TaskKey[T])(implicit format: Format[T]): Initialize[Task[Option[T]]] =
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ import sbt.util.Level
|
||||||
|
|
||||||
import sys.error
|
import sys.error
|
||||||
import scala.xml.NodeSeq
|
import scala.xml.NodeSeq
|
||||||
|
import scala.util.control.NonFatal
|
||||||
import org.apache.ivy.core.module.{ descriptor, id }
|
import org.apache.ivy.core.module.{ descriptor, id }
|
||||||
import descriptor.ModuleDescriptor, id.ModuleRevisionId
|
import descriptor.ModuleDescriptor, id.ModuleRevisionId
|
||||||
import java.io.{ File, PrintWriter }
|
import java.io.{ File, PrintWriter }
|
||||||
|
|
@ -1572,7 +1573,7 @@ object Classpaths {
|
||||||
s.init.evaluate(empty) map { _ -> s.pos }
|
s.init.evaluate(empty) map { _ -> s.pos }
|
||||||
}: _*)
|
}: _*)
|
||||||
} catch {
|
} catch {
|
||||||
case _: Throwable => Map()
|
case NonFatal(e) => Map()
|
||||||
}
|
}
|
||||||
|
|
||||||
val outCacheFile = cacheFile / "output_dsp"
|
val outCacheFile = cacheFile / "output_dsp"
|
||||||
|
|
|
||||||
|
|
@ -333,7 +333,7 @@ object BuiltinCommands {
|
||||||
} yield () => {
|
} yield () => {
|
||||||
def export0(s: State): State = lastImpl(s, kvs, Some(ExportStream))
|
def export0(s: State): State = lastImpl(s, kvs, Some(ExportStream))
|
||||||
val newS = try f() catch {
|
val newS = try f() catch {
|
||||||
case e: Exception =>
|
case NonFatal(e) =>
|
||||||
try export0(s)
|
try export0(s)
|
||||||
finally { throw e }
|
finally { throw e }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ import RichURI.fromURI
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
||||||
import scala.sys.process.Process
|
import scala.sys.process.Process
|
||||||
|
import scala.util.control.NonFatal
|
||||||
|
|
||||||
object Resolvers {
|
object Resolvers {
|
||||||
type Resolver = BuildLoader.Resolver
|
type Resolver = BuildLoader.Resolver
|
||||||
|
|
@ -147,7 +148,7 @@ object Resolvers {
|
||||||
try {
|
try {
|
||||||
f
|
f
|
||||||
} catch {
|
} catch {
|
||||||
case e: Throwable =>
|
case NonFatal(e) =>
|
||||||
IO.delete(file)
|
IO.delete(file)
|
||||||
throw e
|
throw e
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package sbt
|
package sbt
|
||||||
|
|
||||||
|
import scala.util.control.NonFatal
|
||||||
|
|
||||||
import sbt.internal.util.{ AttributeMap, IMap, Types }
|
import sbt.internal.util.{ AttributeMap, IMap, Types }
|
||||||
|
|
||||||
import Def.ScopedKey
|
import Def.ScopedKey
|
||||||
|
|
@ -53,7 +55,7 @@ object SessionVar {
|
||||||
def read[T](key: ScopedKey[Task[T]], state: State)(implicit f: Format[T]): Option[T] =
|
def read[T](key: ScopedKey[Task[T]], state: State)(implicit f: Format[T]): Option[T] =
|
||||||
Project.structure(state).streams(state).use(key) { s =>
|
Project.structure(state).streams(state).use(key) { s =>
|
||||||
try { Some(Operations.read(s.readBinary(key, DefaultDataID))) }
|
try { Some(Operations.read(s.readBinary(key, DefaultDataID))) }
|
||||||
catch { case e: Exception => None }
|
catch { case NonFatal(e) => None }
|
||||||
}
|
}
|
||||||
|
|
||||||
def load[T](key: ScopedKey[Task[T]], state: State)(implicit f: Format[T]): Option[T] =
|
def load[T](key: ScopedKey[Task[T]], state: State)(implicit f: Format[T]): Option[T] =
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import sbt.internal.util.Attributed
|
||||||
// import sbt.internal.{ BuildDef, IncompatiblePluginsException, OldPlugin }
|
// import sbt.internal.{ BuildDef, IncompatiblePluginsException, OldPlugin }
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
|
import scala.util.control.NonFatal
|
||||||
import Attributed.data
|
import Attributed.data
|
||||||
import sbt.internal.BuildDef.analyzed
|
import sbt.internal.BuildDef.analyzed
|
||||||
import xsbt.api.{ Discovered, Discovery }
|
import xsbt.api.{ Discovered, Discovery }
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package sbt
|
package sbt
|
||||||
|
|
||||||
|
import scala.util.control.NonFatal
|
||||||
import org.scalacheck._
|
import org.scalacheck._
|
||||||
import Prop._
|
import Prop._
|
||||||
import Project.project
|
import Project.project
|
||||||
|
|
@ -27,7 +28,7 @@ object ProjectMacro extends Properties("ProjectMacro") {
|
||||||
def secure(f: => Prop): Prop = try {
|
def secure(f: => Prop): Prop = try {
|
||||||
Prop.secure(f)
|
Prop.secure(f)
|
||||||
} catch {
|
} catch {
|
||||||
case e: Throwable =>
|
case NonFatal(e) =>
|
||||||
e.printStackTrace
|
e.printStackTrace
|
||||||
throw e
|
throw e
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import scala.util.control.NonFatal
|
||||||
import sbt._
|
import sbt._
|
||||||
import Keys._
|
import Keys._
|
||||||
import StringUtilities.normalize
|
import StringUtilities.normalize
|
||||||
|
|
@ -164,5 +165,5 @@ object Licensed {
|
||||||
def extractLicenses0(base: File, note: File, s: TaskStreams): Seq[File] =
|
def extractLicenses0(base: File, note: File, s: TaskStreams): Seq[File] =
|
||||||
if (!note.exists) Nil else
|
if (!note.exists) Nil else
|
||||||
try { seePaths(base, IO.read(note)) }
|
try { seePaths(base, IO.read(note)) }
|
||||||
catch { case e: Exception => s.log.warn("Could not read NOTICE"); Nil }
|
catch { case NonFatal(e) => s.log.warn("Could not read NOTICE"); Nil }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ package test
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.nio.charset.Charset
|
import java.nio.charset.Charset
|
||||||
|
|
||||||
|
import scala.util.control.NonFatal
|
||||||
|
|
||||||
import xsbt.IPC
|
import xsbt.IPC
|
||||||
import sbt.internal.scripted.{ CommentHandler, FileCommands, ScriptRunner, TestScriptParser, TestException }
|
import sbt.internal.scripted.{ CommentHandler, FileCommands, ScriptRunner, TestScriptParser, TestException }
|
||||||
import sbt.io.{ DirectoryFilter, GlobFilter, HiddenFileFilter, Path }
|
import sbt.io.{ DirectoryFilter, GlobFilter, HiddenFileFilter, Path }
|
||||||
|
|
@ -98,7 +100,7 @@ final class ScriptedTests(resourceBaseDirectory: File, bufferLog: Boolean, launc
|
||||||
testFailed()
|
testFailed()
|
||||||
buffered.error(" Mark as passing to remove this failure.")
|
buffered.error(" Mark as passing to remove this failure.")
|
||||||
throw e
|
throw e
|
||||||
case e: Exception =>
|
case NonFatal(e) =>
|
||||||
testFailed()
|
testFailed()
|
||||||
if (!pending) throw e
|
if (!pending) throw e
|
||||||
} finally { buffered.clear() }
|
} finally { buffered.clear() }
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@
|
||||||
*/
|
*/
|
||||||
package sbt
|
package sbt
|
||||||
|
|
||||||
|
import scala.util.control.NonFatal
|
||||||
|
|
||||||
import org.scalacheck.Prop._
|
import org.scalacheck.Prop._
|
||||||
|
|
||||||
object checkResult {
|
object checkResult {
|
||||||
|
|
@ -16,9 +18,9 @@ object checkResult {
|
||||||
case i: Incomplete =>
|
case i: Incomplete =>
|
||||||
println(i)
|
println(i)
|
||||||
"One or more tasks failed" |: false
|
"One or more tasks failed" |: false
|
||||||
case e: Throwable =>
|
case NonFatal(e) =>
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
"Error in framework" |: false
|
"Error in framework" |: false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ package sbt
|
||||||
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.net.URLClassLoader
|
import java.net.URLClassLoader
|
||||||
|
import scala.util.control.NonFatal
|
||||||
import testing.{ Logger => TLogger, Task => TestTask, _ }
|
import testing.{ Logger => TLogger, Task => TestTask, _ }
|
||||||
import org.scalatools.testing.{ Framework => OldFramework }
|
import org.scalatools.testing.{ Framework => OldFramework }
|
||||||
import sbt.internal.inc.classpath.{ ClasspathUtilities, DualLoader, FilteredLoader }
|
import sbt.internal.inc.classpath.{ ClasspathUtilities, DualLoader, FilteredLoader }
|
||||||
|
|
@ -89,7 +90,7 @@ final class TestRunner(delegate: Runner, listeners: Seq[TestReportListener], log
|
||||||
safeListenersCall(_.endGroup(name, suiteResult.result))
|
safeListenersCall(_.endGroup(name, suiteResult.result))
|
||||||
(suiteResult, nestedTasks)
|
(suiteResult, nestedTasks)
|
||||||
} catch {
|
} catch {
|
||||||
case e: Throwable =>
|
case NonFatal(e) =>
|
||||||
safeListenersCall(_.endGroup(name, e))
|
safeListenersCall(_.endGroup(name, e))
|
||||||
(SuiteResult.Error, Seq.empty[TestTask])
|
(SuiteResult.Error, Seq.empty[TestTask])
|
||||||
}
|
}
|
||||||
|
|
@ -107,7 +108,7 @@ object TestFramework {
|
||||||
}
|
}
|
||||||
|
|
||||||
private[sbt] def safeForeach[T](it: Iterable[T], log: Logger)(f: T => Unit): Unit =
|
private[sbt] def safeForeach[T](it: Iterable[T], log: Logger)(f: T => Unit): Unit =
|
||||||
it.foreach(i => try f(i) catch { case e: Exception => log.trace(e); log.error(e.toString) })
|
it.foreach(i => try f(i) catch { case NonFatal(e) => log.trace(e); log.error(e.toString) })
|
||||||
|
|
||||||
private[sbt] def hashCode(f: Fingerprint): Int = f match {
|
private[sbt] def hashCode(f: Fingerprint): Int = f match {
|
||||||
case s: SubclassFingerprint => (s.isModule, s.superclassName).hashCode
|
case s: SubclassFingerprint => (s.isModule, s.superclassName).hashCode
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue