summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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) {