How to use jsr-223 to access Java exceptions that cause scriptexceptions

I'm using jre6's built-in jsr-223 scripting engine to execute JavaScript JavaScript provides access to Java code and objects When an exception is thrown from Java code executed from JavaScript, scriptengine will throw a scriptexception

I want to be able to access Java exceptions that cause JavaScript to throw exceptions

From JavaScript, I can catch exceptions and view the exception's javaexception field:

However, I have no control over JavaScript and can only execute them from scriptengine Is there any way to get "inner" Java exceptions from scriptexception?

I believe that if I use rhino, rhinoexception will have a Java exception available The jsr-223 API does not provide rhinoexception

Solution

Have you tried e.getcause()?

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>