Skip to content

Commit

Permalink
Do not crash when code error (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
grios-stratio authored Feb 20, 2019
1 parent 8d62535 commit f305b0d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Only listing significant user-visible, not internal code cleanups and minor bug
## 0.2.0 (February 08, 2019)

* Update upstream toree to 0.3.0-incubating
* Do not crash interpreter when receiving a code error

## 0.1.0-491c615 (Built: September 03, 2018 | Released: September 14, 2018)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,18 +339,18 @@ class ScalaInterpreter(private val config:Config = ConfigFactory.load) extends I
lastResultOut.reset()

val (obj, defStr, text) = prepareResult(lastOutput, KernelOptions.showTypes, KernelOptions.noTruncation, KernelOptions.showOutput )
defStr.foreach(kernel.display.content(MIMEType.PlainText, _))
text.foreach(kernel.display.content(MIMEType.PlainText, _))
// defStr.foreach(kernel.display.content(MIMEType.PlainText, _))
// text.foreach(kernel.display.content(MIMEType.PlainText, _))
val output = obj.map(Displayers.display(_).asScala.toMap).getOrElse(Map.empty)
(result, Left(output))

case Results.Error =>
val lastOutput = lastResultOut.toString("UTF-8").trim
lastResultOut.reset()

val (obj, defStr, text) = prepareResult(lastOutput)
val (obj, defStr, text) = prepareResult(lastOutput, KernelOptions.showTypes, KernelOptions.noTruncation, true)
defStr.foreach(kernel.display.content(MIMEType.PlainText, _))
val output = interpretConstructExecuteError(text.get)
val output = interpretConstructExecuteError(text.getOrElse(""))
(Results.Error, Right(output))

case Results.Aborted =>
Expand Down

0 comments on commit f305b0d

Please sign in to comment.