diff options
author | Paul Phillips <paulp@improving.org> | 2010-11-26 03:54:19 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-11-26 03:54:19 +0000 |
commit | 9382d7ca14d65660b9589a7172c226bc00bd851c (patch) | |
tree | 840408e7274c07da6a8c337c6c50beb6f1d20764 /src | |
parent | a16bba97a013cc7cb8bb7fa8815b4683efa4324a (diff) | |
download | scala-9382d7ca14d65660b9589a7172c226bc00bd851c.tar.gz scala-9382d7ca14d65660b9589a7172c226bc00bd851c.tar.bz2 scala-9382d7ca14d65660b9589a7172c226bc00bd851c.zip |
In the absence of known reasons why some except...
In the absence of known reasons why some exceptions are intercepted or
have their stack trace printed and others fly unchallenged, changed
script and object runners to handle everything consistently when an
exception is thrown. Closes #3978 again, no review.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/ObjectRunner.scala | 7 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/ScriptRunner.scala | 8 |
2 files changed, 5 insertions, 10 deletions
diff --git a/src/compiler/scala/tools/nsc/ObjectRunner.scala b/src/compiler/scala/tools/nsc/ObjectRunner.scala index 987a6b0ba0..16793996bb 100644 --- a/src/compiler/scala/tools/nsc/ObjectRunner.scala +++ b/src/compiler/scala/tools/nsc/ObjectRunner.scala @@ -9,6 +9,7 @@ package scala.tools.nsc import java.net.URL import util.ScalaClassLoader import java.lang.reflect.InvocationTargetException +import util.Exceptional.unwrap /** An object that runs another object specified by name. * @@ -37,10 +38,6 @@ object ObjectRunner { */ def runAndCatch(urls: List[URL], objectName: String, arguments: Seq[String]): Either[Throwable, Unit] = { try Right(run(urls, objectName, arguments)) - catch { - case e: ClassNotFoundException => Left(e) - case e: NoSuchMethodException => Left(e) - case e: InvocationTargetException => Left(e.getCause match { case null => e ; case cause => cause }) - } + catch { case e => Left(unwrap(e)) } } } diff --git a/src/compiler/scala/tools/nsc/ScriptRunner.scala b/src/compiler/scala/tools/nsc/ScriptRunner.scala index c432e1c9f0..c43542c348 100644 --- a/src/compiler/scala/tools/nsc/ScriptRunner.scala +++ b/src/compiler/scala/tools/nsc/ScriptRunner.scala @@ -19,6 +19,7 @@ import java.util.jar.{ JarEntry, JarOutputStream } import util.{ waitingForThreads, addShutdownHook } import scala.tools.util.PathResolver import scala.tools.nsc.reporters.{Reporter,ConsoleReporter} +import util.Exceptional.unwrap /** An object that runs Scala code in script files. * @@ -242,7 +243,7 @@ object ScriptRunner { val classpath = File(compiledLocation).toURL +: pr.asURLs ObjectRunner.runAndCatch(classpath, scriptMain(settings), scriptArgs) match { - case Left(ex) => Console println ex ; false + case Left(ex) => ex.printStackTrace() ; false case _ => true } } @@ -272,10 +273,7 @@ object ScriptRunner { scriptArgs: List[String]): Either[Throwable, Boolean] = { try Right(runScript(settings, scriptFile, scriptArgs)) - catch { - case e: IOException => Left(e) - case e: SecurityException => Left(e) - } + catch { case e => Left(unwrap(e)) } } /** Run a command |