typesafehub / js-engine

A JavaScript Engine Library - provides an abstract of a means to execute JavaScript code where no browser is involved.
Other
72 stars 20 forks source link

JavaScript exceptions are not caught by the Rhino engine #21

Closed tgambet closed 10 years ago

tgambet commented 10 years ago

There is no test in RhinoSpec.scala that checks that JavaScripts exceptions are correctly caught, and as a matter of fact they are not.

Consider the following:

val system = ActorSystem()
val engine = system.actorOf(Rhino.props())
val f = new File(classOf[RhinoSpec].getResource("test-node.js").toURI)
implicit val timeout = Timeout(5000L, TimeUnit.MILLISECONDS)

val futureResult = (engine ? Engine.ExecuteJs(f, immutable.Seq("999"), timeout.duration)).mapTo[JsExecutionResult]
val result = Await.result(futureResult, timeout.duration)
new String(result.error.toArray, "UTF-8").trim must_!= ""

Since we are running a node.js script inside a Rhino engine we expect some exception to be caught, but the test fails. The exception is written on stdout (Error: Module "console" not found) but not in result.error.

huntc commented 10 years ago

Thanks! PR?

As previously stated though I might just drop pure Rhino...

tgambet commented 10 years ago

So support for Rhino shell scripts would be simply dropped? Or does Trireme allows to execute them without adding node.js API (I might have misunderstood Trireme)?

In any case I think there are use cases where people would want to execute whatever Rhino script they have inside of sbt, so in my opinion it makes sense to keep that functionality.

huntc commented 10 years ago

Understood. Closing this then w.r.t. issue #23...