Given the following simple Java class defined using JSInterop:
@JsType(name = "ExceptionTest", namespace = JsPackage.GLOBAL)
public class ExceptionTest {
public static void triggerTypeErrorWhenNull(Object object) {
object.toString();
}
}
Which is called in JavaScript as follows:
setTimeout(function timerTrigger() {
function test1() {
ExceptionTest.triggerTypeErrorWhenNull(null);
}
test1();
}, 100);
The following stacktrace is emitted when the exception occurs:
Uncaught TypeError: Cannot read property 'toString' of null
at toString_0 (local-0.js:76)
at Function.triggerTypeErrorWhenNull (local-0.js:1319)
My question is how to get the complete stack trace for the error that occurred; that is a stack trace that includes the location where the JSInterop method was invoked in JavaScript (test1()
).
Here a link to the project with the complete source code for the example: ExceptionTest.java