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
|
||||
|
||||
import scala.annotation.tailrec
|
||||
import scala.util.control.NonFatal
|
||||
import java.io.{ File, PrintWriter }
|
||||
import jline.TerminalFactory
|
||||
|
||||
|
|
@ -52,7 +53,7 @@ object MainLoop {
|
|||
case e: xsbti.FullReload =>
|
||||
deleteLastLog(logBacking)
|
||||
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)
|
||||
deleteLastLog(logBacking)
|
||||
throw e
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ package xsbt
|
|||
import java.io.{ BufferedReader, BufferedWriter, InputStream, InputStreamReader, OutputStreamWriter, OutputStream }
|
||||
import java.net.{ InetAddress, ServerSocket, Socket }
|
||||
|
||||
import scala.util.control.NonFatal
|
||||
|
||||
object IPC {
|
||||
private val portMin = 1025
|
||||
private val portMax = 65536
|
||||
|
|
@ -28,7 +30,7 @@ object IPC {
|
|||
def createServer(attempts: Int): ServerSocket =
|
||||
if (attempts > 0)
|
||||
try { new ServerSocket(nextPort, 1, loopback) }
|
||||
catch { case _: Exception => createServer(attempts - 1) }
|
||||
catch { case NonFatal(e) => createServer(attempts - 1) }
|
||||
else
|
||||
sys.error("Could not connect to socket: maximum attempts exceeded")
|
||||
createServer(10)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@ import sbt.internal.util.{ ~>, AttributeKey, IMap, RMap }
|
|||
import sbt.internal.util.Types._
|
||||
|
||||
import java.io.{ InputStream, OutputStream }
|
||||
|
||||
import scala.util.control.NonFatal
|
||||
|
||||
import sbinary.{ DefaultProtocol, Format }
|
||||
import DefaultProtocol.{ StringFormat, withStamp }
|
||||
|
||||
|
|
@ -76,11 +79,11 @@ object Previous {
|
|||
|
||||
private def read[T](stream: InputStream, format: Format[T]): Option[T] =
|
||||
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 =
|
||||
try format.writes(stream, value)
|
||||
catch { case e: Exception => () }
|
||||
catch { case NonFatal(e) => () }
|
||||
|
||||
/** Public as a macro implementation detail. Do not call directly. */
|
||||
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 scala.xml.NodeSeq
|
||||
import scala.util.control.NonFatal
|
||||
import org.apache.ivy.core.module.{ descriptor, id }
|
||||
import descriptor.ModuleDescriptor, id.ModuleRevisionId
|
||||
import java.io.{ File, PrintWriter }
|
||||
|
|
@ -1572,7 +1573,7 @@ object Classpaths {
|
|||
s.init.evaluate(empty) map { _ -> s.pos }
|
||||
}: _*)
|
||||
} catch {
|
||||
case _: Throwable => Map()
|
||||
case NonFatal(e) => Map()
|
||||
}
|
||||
|
||||
val outCacheFile = cacheFile / "output_dsp"
|
||||
|
|
|
|||
|
|
@ -333,7 +333,7 @@ object BuiltinCommands {
|
|||
} yield () => {
|
||||
def export0(s: State): State = lastImpl(s, kvs, Some(ExportStream))
|
||||
val newS = try f() catch {
|
||||
case e: Exception =>
|
||||
case NonFatal(e) =>
|
||||
try export0(s)
|
||||
finally { throw e }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import RichURI.fromURI
|
|||
import java.util.Locale
|
||||
|
||||
import scala.sys.process.Process
|
||||
import scala.util.control.NonFatal
|
||||
|
||||
object Resolvers {
|
||||
type Resolver = BuildLoader.Resolver
|
||||
|
|
@ -147,7 +148,7 @@ object Resolvers {
|
|||
try {
|
||||
f
|
||||
} catch {
|
||||
case e: Throwable =>
|
||||
case NonFatal(e) =>
|
||||
IO.delete(file)
|
||||
throw e
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package sbt
|
||||
|
||||
import scala.util.control.NonFatal
|
||||
|
||||
import sbt.internal.util.{ AttributeMap, IMap, Types }
|
||||
|
||||
import Def.ScopedKey
|
||||
|
|
@ -53,7 +55,7 @@ object SessionVar {
|
|||
def read[T](key: ScopedKey[Task[T]], state: State)(implicit f: Format[T]): Option[T] =
|
||||
Project.structure(state).streams(state).use(key) { s =>
|
||||
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] =
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import sbt.internal.util.Attributed
|
|||
// import sbt.internal.{ BuildDef, IncompatiblePluginsException, OldPlugin }
|
||||
import java.io.File
|
||||
import java.net.URL
|
||||
import scala.util.control.NonFatal
|
||||
import Attributed.data
|
||||
import sbt.internal.BuildDef.analyzed
|
||||
import xsbt.api.{ Discovered, Discovery }
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package sbt
|
||||
|
||||
import scala.util.control.NonFatal
|
||||
import org.scalacheck._
|
||||
import Prop._
|
||||
import Project.project
|
||||
|
|
@ -27,7 +28,7 @@ object ProjectMacro extends Properties("ProjectMacro") {
|
|||
def secure(f: => Prop): Prop = try {
|
||||
Prop.secure(f)
|
||||
} catch {
|
||||
case e: Throwable =>
|
||||
case NonFatal(e) =>
|
||||
e.printStackTrace
|
||||
throw e
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import scala.util.control.NonFatal
|
||||
import sbt._
|
||||
import Keys._
|
||||
import StringUtilities.normalize
|
||||
|
|
@ -164,5 +165,5 @@ object Licensed {
|
|||
def extractLicenses0(base: File, note: File, s: TaskStreams): Seq[File] =
|
||||
if (!note.exists) Nil else
|
||||
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.nio.charset.Charset
|
||||
|
||||
import scala.util.control.NonFatal
|
||||
|
||||
import xsbt.IPC
|
||||
import sbt.internal.scripted.{ CommentHandler, FileCommands, ScriptRunner, TestScriptParser, TestException }
|
||||
import sbt.io.{ DirectoryFilter, GlobFilter, HiddenFileFilter, Path }
|
||||
|
|
@ -98,7 +100,7 @@ final class ScriptedTests(resourceBaseDirectory: File, bufferLog: Boolean, launc
|
|||
testFailed()
|
||||
buffered.error(" Mark as passing to remove this failure.")
|
||||
throw e
|
||||
case e: Exception =>
|
||||
case NonFatal(e) =>
|
||||
testFailed()
|
||||
if (!pending) throw e
|
||||
} finally { buffered.clear() }
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
*/
|
||||
package sbt
|
||||
|
||||
import scala.util.control.NonFatal
|
||||
|
||||
import org.scalacheck.Prop._
|
||||
|
||||
object checkResult {
|
||||
|
|
@ -16,9 +18,9 @@ object checkResult {
|
|||
case i: Incomplete =>
|
||||
println(i)
|
||||
"One or more tasks failed" |: false
|
||||
case e: Throwable =>
|
||||
case NonFatal(e) =>
|
||||
e.printStackTrace()
|
||||
"Error in framework" |: false
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ package sbt
|
|||
|
||||
import java.io.File
|
||||
import java.net.URLClassLoader
|
||||
import scala.util.control.NonFatal
|
||||
import testing.{ Logger => TLogger, Task => TestTask, _ }
|
||||
import org.scalatools.testing.{ Framework => OldFramework }
|
||||
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))
|
||||
(suiteResult, nestedTasks)
|
||||
} catch {
|
||||
case e: Throwable =>
|
||||
case NonFatal(e) =>
|
||||
safeListenersCall(_.endGroup(name, e))
|
||||
(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 =
|
||||
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 {
|
||||
case s: SubclassFingerprint => (s.isModule, s.superclassName).hashCode
|
||||
|
|
|
|||
Loading…
Reference in New Issue