Yeah. It's because you get your scripts from a url resource. That's
what I do too.
In my catch I do a replace:
String scriptSource = "save your source file name";
try {
script.eval(bindings);
} catch (ScriptException e) {
// We need to LOG and THROW. Log ensures that we get a CAUSED BY to
see where exactly
// an error could occur. Otherwise we'll only know where in the
script the problem is
// not where in the java code.
log.error(e.getMessage(), e);
// Since we pass a reader the exception will not have the source
// file name. We'll do a String replace to put it in there.
String msg = e.getMessage();
msg = StringUtil.replace(msg, "<Unknown Source>", scriptSource);
throw new ScriptException(msg);
}
On 5/1/2010 8:44 PM, Lord.Quackstar wrote:
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.
Thanks,
Leon
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino