summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2013-05-17 16:22:06 -0700
committerAdriaan Moors <adriaan.moors@typesafe.com>2013-05-17 16:22:06 -0700
commite2f094bcbbaf6d442c4ecd1ad32661353d1cf6b3 (patch)
tree66e7d26ae61eb3040038f245da8aefa5c0115e68
parent40bb3df10cfef9c5f63ae4b609845cabc52db828 (diff)
parent0bece25e87b80b5e608691ee619754453afdf9a1 (diff)
downloadscala-e2f094bcbbaf6d442c4ecd1ad32661353d1cf6b3.tar.gz
scala-e2f094bcbbaf6d442c4ecd1ad32661353d1cf6b3.tar.bz2
scala-e2f094bcbbaf6d442c4ecd1ad32661353d1cf6b3.zip
Merge pull request #2541 from rjolly/scripting11
ScriptEngine.eval() forwards Error instead of new ScriptException
-rw-r--r--src/repl/scala/tools/nsc/interpreter/IMain.scala10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/repl/scala/tools/nsc/interpreter/IMain.scala b/src/repl/scala/tools/nsc/interpreter/IMain.scala
index 379751b9a7..3a71930383 100644
--- a/src/repl/scala/tools/nsc/interpreter/IMain.scala
+++ b/src/repl/scala/tools/nsc/interpreter/IMain.scala
@@ -597,11 +597,19 @@ class IMain(@BeanProperty val factory: ScriptEngineFactory, initialSettings: Set
private class WrappedRequest(val req: Request) extends CompiledScript {
var recorded = false
+ /** In Java we would have to wrap any checked exception in the declared
+ * ScriptException. Runtime exceptions and errors would be ok and would
+ * not need to be caught. So let us do the same in Scala : catch and
+ * wrap any checked exception, and let runtime exceptions and errors
+ * escape. We could have wrapped runtime exceptions just like other
+ * exceptions in ScriptException, this is a choice.
+ */
@throws(classOf[ScriptException])
def eval(context: ScriptContext): Object = {
val result = req.lineRep.evalEither match {
+ case Left(e: RuntimeException) => throw e
case Left(e: Exception) => throw new ScriptException(e)
- case Left(_) => throw new ScriptException("run-time error")
+ case Left(e) => throw e
case Right(result) => result.asInstanceOf[Object]
}
if (!recorded) {