Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get cause of ScriptException when compiling with JSR223 #8441

Closed
scabug opened this issue Mar 25, 2014 · 4 comments
Closed

Get cause of ScriptException when compiling with JSR223 #8441

scabug opened this issue Mar 25, 2014 · 4 comments

Comments

@scabug
Copy link

scabug commented Mar 25, 2014

When calling compile method on IMain (JSR223 ScriptEngine) with an invalid script, ScriptException is thrown with no other information than the message: "compile-time error". It should be thrown with an error message coming from the compiler, and also with the lineNumber and columnNumber arguments.

It should throw the same ScriptException content as when calling eval method.

It's quite inconvenient when embedding Scala in a end-user application with a JSR223 Script Editor, along with others languages (see attached screenshots). The Script Editor calls compile to validate the script from user invalid input through JSR223 API, and display message from ScriptException to the user if it fails to compile.

Others ScriptEngine implementations (Groovy, MVEL, Jython ...) provides usefull those information on compilation errors (line number, column number, compiler message).

@scabug
Copy link
Author

scabug commented Mar 25, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8441?orig=1
Reporter: Rémi Alvergnat (Toilal)
Affected Versions: 2.11.0-RC3
Attachments:

  • groovy.png (created on Mar 25, 2014 11:23:43 AM UTC, 41442 bytes)
  • scala.png (created on Mar 25, 2014 11:23:43 AM UTC, 19658 bytes)

@scabug
Copy link
Author

scabug commented Apr 4, 2014

@rjolly said:
Workaround : look at the console.

printlm("hello world")

:11: error: not found: value printlm
printlm("hello world")
^

Fixing this may be possible using the "reporter" in scala.tools.nsc.interpreter.IMain

@scabug
Copy link
Author

scabug commented Apr 4, 2014

@som-snytt said:
Thanks, my fix uses a custom reporter for the position; funnily, the column is offset by the embedding template.

So after correcting column, it seems line could be the repl's internal line counter, too.

@scabug
Copy link
Author

scabug commented Apr 28, 2016

@som-snytt said:
scala/scala#4819

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants