NativeError does not support fileName and lineNumber; catching Java exceptions does not work
rjb3977 opened this issue ยท 0 comments
NativeError contains "constructor", "toString", and "toSource" in its prototype, but neither "fileName" nor "lineNumber". This causes a problem because NativeError::make sets those properties if the respective arguments are passed. This can be reproduced with:
new SyntaxError("", "");
This also causes actual problems when trying to catch exceptions thrown in Java code, because ScriptRuntime::newCatchScope provides fileName and lineNumber. This can be reproduced with:
try {
Integer.parseInt("");
} catch(e) {
console.log("caught error");
}
I found this using KubeJS on 1.19 with Rhino 1802.1.14-build.225. I tried using 1802.2.0-build.232, but it doesn't seem there's a KubeJS release for 1.19 that supports that version.