tags:

views:

97

answers:

1

Hello everyone,

In my code, all of the scripts are contained in .js files. Whenever one of the scripts contains an error, I get this:

javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "nonexistant" is not defined. (<Unknown source>#5) in <Unknown source> at line number 5

What bugs me is the <Unknown Source>. Multiple files are in one ScriptContext, and it can be hard to track down an error. It also looks horrible.

Is there a way to replace <Unknown Source> with the actual file name? None of the methods I see support passing a File object, so I'm really confused here.

+2  A: 

Use the ScriptEngine.FILENAME constant:

scriptEngine.put(ScriptEngine.FILENAME, scriptFile.toString());

Kevin Krouse
Thanks, it works!
TheLQ