override def execute()

in scala-interpreter/src/main/scala/org/apache/toree/magic/builtin/Scala.scala [30:53]


  override def execute(code: String): MagicOutput = {
    val scala = kernel.interpreter("Scala")

    if (scala.isEmpty || scala.get == null)
      throw new ScalaException("Scala is not available!")

    scala.get match {
      case scalaInterpreter: ScalaInterpreter =>
        val (_, output) = scalaInterpreter.interpret(code)
        output match {
          case Left(executeOutput) =>
            MagicOutput(executeOutput.toSeq:_*)
          case Right(executeFailure) => executeFailure match {
            case executeAborted: ExecuteAborted =>
              throw new ScalaException("Scala code was aborted!")
            case executeError: ExecuteError =>
              throw new ScalaException(executeError.value)
          }
        }
      case otherInterpreter =>
        val className = otherInterpreter.getClass.getName
        throw new ScalaException(s"Invalid Scala interpreter: $className")
    }
  }