Replace <Unknown Source> in Java Rhino (JSR223) with actual file name
Posted
by Lord.Quackstar
on Stack Overflow
See other posts from Stack Overflow
or by Lord.Quackstar
Published on 2010-05-21T19:50:21Z
Indexed on
2010/05/21
20:00 UTC
Read the original article
Hit count: 165
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.
© Stack Overflow or respective owner