@ThreadSafe public final class ScriptExceptionX extends Object
Assume a script is invoked from Java, and it calls back into the Java machine. If
a Java exception is thrown there (x
), then the invoker will end up with a
ScriptException (xS
) that fails to wrap it. Printing the stack trace of
xS
, for example, will not reveal the line number of the ultimate cause
(x
). To get that information, you need to print the trace from the
JavaScript side, with code such as this:
try { // call into Java } catch( e ) { if( e.rhinoException != null ) e.rhinoException.printStackTrace(); else if( e.javaException != null ) e.javaException.printStackTrace(); else if( e instanceof Error ) println( e.name + ': ' + e.message ); else println( e ); throw e; }