try {
if (typeof hostObj['propertyItDoesntHave'] === "undefined") {
throw new Error('first');
}
} catch (e) {
throw new Error('second');
}
For me, this is always crashing with:
org.graalvm.polyglot.PolyglotException: Error: first
at <js>.:anonymous(Unnamed:21) ~[?:?]
at <js>.:=>(Unnamed:21) ~[?:?]
at <js>.:=>(Unnamed:21) ~[?:?]
i.e. the catch block is never reached, the first error seems to be stopping the program.
How can I get the GraalVM JavaScript interpreter to catch nested errors like this?
I think it should work out of the box. If it doesn't it is probably a bug. Can you please submit an issue to https://github.com/oracle/graaljs.
It does work for me in the simplest test, I'm trying on the latest release 21.1 both
node
andjs
.Also when embedding JS in a Java application:
I do get the second: