Skip to content

Commit

Permalink
Check and report errors during predef (#217)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexarchambault authored Sep 5, 2018
1 parent 8aaa1d7 commit f340cda
Showing 1 changed file with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,24 @@ final class ScalaInterpreter(
else
predef

val stmts = Parsers.split(code).get.get.value
ammInterp0.processLine(code, stmts, -1, silent = true, () => ())
def handlePredef(): Unit = {
val stmts = Parsers.split(code).get.get.value
val predefRes = ammInterp0.processLine(code, stmts, 9999999, silent = false, () => ())
Repl.handleOutput(ammInterp0, predefRes)
predefRes match {
case Res.Success(_) =>
case Res.Failure(msg) =>
log.error(s"Error while running predef: $msg")
sys.exit(1)
case Res.Exception(t, msg) =>
log.error(s"Caught exception while running predef ($msg)", t)
case Res.Skip =>
case Res.Exit(v) =>
log.warn(s"Ignoring exit request from predef (exit value: $v)")
}
}

handlePredef()

log.info("Ammonite interpreter ok")

Expand Down

0 comments on commit f340cda

Please sign in to comment.