diff options
author | Som Snytt <som.snytt@gmail.com> | 2014-03-15 02:14:01 -0700 |
---|---|---|
committer | Som Snytt <som.snytt@gmail.com> | 2014-03-15 02:14:01 -0700 |
commit | 47c03aa5a8fc0d66c28574b6029fa3f150a6a4e9 (patch) | |
tree | 26a0a2df861e244a1e0378a75b5b0e478f567e0d /src/repl/scala/tools/nsc/interpreter/ILoop.scala | |
parent | 492624d729730d594097aa618f8f1e34caa79639 (diff) | |
download | scala-47c03aa5a8fc0d66c28574b6029fa3f150a6a4e9.tar.gz scala-47c03aa5a8fc0d66c28574b6029fa3f150a6a4e9.tar.bz2 scala-47c03aa5a8fc0d66c28574b6029fa3f150a6a4e9.zip |
SI-8415 Exception handling in REPL init
Incremental robustness, and probe for typer phase.
The probe would be unnecessary if repl contributed a
terminal phase that "requires" whatever it needs; that
is checked when the Run is built.
Diffstat (limited to 'src/repl/scala/tools/nsc/interpreter/ILoop.scala')
-rw-r--r-- | src/repl/scala/tools/nsc/interpreter/ILoop.scala | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/repl/scala/tools/nsc/interpreter/ILoop.scala b/src/repl/scala/tools/nsc/interpreter/ILoop.scala index a96bed4696..ce0eadc04f 100644 --- a/src/repl/scala/tools/nsc/interpreter/ILoop.scala +++ b/src/repl/scala/tools/nsc/interpreter/ILoop.scala @@ -402,7 +402,13 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter) private val crashRecovery: PartialFunction[Throwable, Boolean] = { case ex: Throwable => - echo(intp.global.throwableAsString(ex)) + val (err, explain) = ( + if (intp.isInitializeComplete) + (intp.global.throwableAsString(ex), "") + else + (ex.getMessage, "The compiler did not initialize.\n") + ) + echo(err) ex match { case _: NoSuchMethodError | _: NoClassDefFoundError => @@ -410,7 +416,7 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter) throw ex case _ => def fn(): Boolean = - try in.readYesOrNo(replayQuestionMessage, { echo("\nYou must enter y or n.") ; fn() }) + try in.readYesOrNo(explain + replayQuestionMessage, { echo("\nYou must enter y or n.") ; fn() }) catch { case _: RuntimeException => false } if (fn()) replay() |