Just adding to what Attila said:

For ECMAScript Error objects there is a property called "nashornException" that returns the underlying Java exception thrown.

try {
     func();
} catch (e) {
     print(e.nashornException);
}

Java exceptions are thrown "as is" (no wrapping of Java exceptions as ECMAScript objects)

-Sundar

On Monday 30 December 2013 04:07 PM, Attila Szegedi wrote:
We don't wrap them initially, so "e" can be a java exception; catch(x if x 
instanceof java.io.FileNotFoundException) should work.

On Dec 30, 2013, at 7:24 AM, Tal Liron <[email protected]> wrote:

How do you catch JVM exceptions in Nashorn? This is how it works in Rhino:

            try {
                ...
            }
            catch (x if x.javaException instanceof 
java.io.FileNotFoundException) {
            }

Reply via email to