Let's say that I have some JS code like this:
(function(foo) {
throw new Error('Sorry, ' + foo);
})
and I execute it by reading it into a String variable, then executing it
using ScriptEngine.eval(string), and then I call the function later, either
from Java directly or from some other JS code.
Right now, in Nashorn, I see that the stack trace of my exception will
include the entry:
"<eval>:2"
to indicate the "file name" and line number of my error.
I would like instead to stick in a file name so that the file name appears
instead of "<eval>". Is there a way for me to do that?
I did try setting the property "ScriptEngine.FILENAME" on my script
context, but that seems to be a global context. It works the first time I
run the script, but if I call the function later on from inside another
script, the file name doesn't "stick" to the code.
I can provide an example if I need to, but is there anything you guys can
think of that I can do in order to get a file name to stick to this
function for the purpose of stack traces?
--
*greg brail* | *apigee <https://apigee.com/>* | twitter
@gbrail<http://twitter.com/gbrail>