I'm executing Javascripts using the JSR-223 script engine built into JRE6. The Javascripts are able to access Java code and objects. When an exception is thrown from the Java code that is executed from a JavaScript, the ScriptEngine will throw a ScriptException.
I want to be able to access the Java exception that caused the Javascript to throw an exception.
From the Javascript, I can catch the exception and look at the javaException field of the exception:
try
{
.
}
catch (e)
{
e.javaException.printStackTrace();
}
However, I don't have control of the Javascript, only the execution of them from the ScriptEngine. Is there a way to grab the "inner" Java exception from the ScriptException?
I believe if I was using Rhino, the RhinoException would have a Java exception available. The RhinoException is not available from the JSR-223 API.
Throwable.getCause()
not do what you are asking? – Cardcarrying