|
||
|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hello everyone,
In my code, I have a bunch of scripts 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. Mirrored at Replace <Unknown Source> in Java Rhino (JSR223) with actual file name - Stack Overflow
Last edited by Lord.Quackstar; 22-05-2010 at 04:10 PM. Reason: Added cross-post notification |
|
|||
|
The file name, line number, and variable name info are included in the class files when compiled with the debug option -g. The JVM exception management can then pick them up from the class files at runtime to provide more informative messages. See Java Compiler Options.
|
|
|||
|
Quote:
|
|
|||
|
You're right, I'm not (well, not that familiar)...
Quote:
I wasn't suggesting it was a compiler error, I was just saying that in order to get the filename and line number of Java source in exception messages, the javac -g debug options should be used when compiling Java source code. Clearly this will only tell you the last Java class file and line executed, not JavaScript innards, but I thought this was a Java question. If it doesn't apply here, then I'm sorry, it won't help
|
|
||||
|
Any chance you can run your Javascript code in a normal browser by including it from a dummy HTML file, that way you could use the browsers Javascript debugger which is probably a lot better than your Java IDE
![]() // Json
__________________
jwebutils - A Java library for creating HTML 5, CSS 3 and JSON markup |
|
|||
|
Quote:
And also this is java scripting, not browser scripting. Surly there's support for this since EcmaError has a spot for the file name. |
|
||||
|
Yes, point taken, I also think it should give you a nicer message than Unknown Source, is there anyway through the ScriptEngine you can set a debug flag of some kind?
I'm not too familiar with the ScriptEngine myself you see. // Json
__________________
jwebutils - A Java library for creating HTML 5, CSS 3 and JSON markup |
![]() |
| Tags |
| ecmaerror, exception, jsr223 |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Vectors - accessing an unknown amount of objects | fox | Loops & Control Statements | 1 | 07-05-2010 08:54 PM |
| What can go wrong if you replace && with & in the following code: | scott01 | Java Theory & Questions | 4 | 12-02-2010 11:47 AM |
| Jsp source not found | jadeite100 | What's Wrong With My Code? | 0 | 15-01-2010 05:00 AM |
| Website Source | expertOpinion | Java Theory & Questions | 10 | 21-07-2009 04:06 PM |
| [SOLVED] books or source for beginners | chronoz13 | Java Theory & Questions | 1 | 15-04-2009 01:36 PM |