protected def interpretConstructExecuteError()

in scala-interpreter/src/main/scala-2.12/org/apache/toree/kernel/interpreter/scala/ScalaInterpreterSpecific.scala [403:440]


  protected def interpretConstructExecuteError(output: String) = {
    Option(retrieveLastException) match {
      // Runtime error
      case Some(e) =>
        val ex = e.asInstanceOf[Throwable]
        clearLastException()

        // The scala REPL does a pretty good job of returning us a stack trace that is free from all the bits that the
        // interpreter uses before it.
        //
        // The REPL emits its message as something like this, so trim off the first and last element
        //
        //    java.lang.ArithmeticException: / by zero
        //    at failure(<console>:17)
        //    at call_failure(<console>:19)
        //    ... 40 elided

        val formattedException = output.split("\n")

        ExecuteError(
          ex.getClass.getName,
          ex.getLocalizedMessage,
          formattedException.toList
        )
      // Compile time error, need to check internal reporter
      case _ =>
        if (iMain.reporter.hasErrors)
        // TODO: This wrapper is not needed when just getting compile
        // error that we are not parsing... maybe have it be purely
        // output and have the error check this?
          ExecuteError(
            "Compile Error", output, List()
          )
        else
        // May as capture the output here.  Could be useful
          ExecuteError("Unknown Error", output, List())
    }
  }