1

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

mxro
  • 6,588
  • 4
  • 35
  • 38
  • The build in your example project can't pass, `de.mxro.process:java-start-process:jar:0.1.1` isn't in maven central. – Colin Alworth Nov 06 '17 at 01:27
  • Thank you for having a look and sorry for the missing dependencies. I have fixed the build now and tested it on [travis-ci](https://travis-ci.org/mxro/mxro-gwt-js-interop-test). – mxro Nov 06 '17 at 04:27
  • @ColinAlworth I have fixed the dependencies as written before but forgot to mention you. As said in my error description my main problem is that I can't get the stacktrace emitted in a method wrapped with JSInterop to include the location where the JSInterop method was called. If I do a manual `console.trace()`, I can get the full stack trace though. Thank you!! – mxro Nov 09 '17 at 22:51
  • Apologies, I was traveling, I'll take a look as soon as I can. I did get the other notification, but on a busy day - an `@` mention isn't required to let someone know. – Colin Alworth Nov 10 '17 at 02:04
  • Okay! Thank you for the clarification. And, no hurries, I am already most delighted that you are having a look. Anything I can do to help or explain further, please let me know. – mxro Nov 10 '17 at 06:47
  • Hi! Did you get a chance to look at this yet? Thank you! – mxro Nov 30 '17 at 01:21

0 Answers0