3

I have this code to handle uncaught exceptions with GWT:

    GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() {
        @Override
        public void onUncaughtException(Throwable throwable) {
            // Iterate over the trace and then print with $wnd.console.log
            printStackTrace(throwable.getStackTrace());
        }
    });

However the log printed in the Browser console looks like this:

"Unknown.Ol(Unknown Source)
Unknown.Nl(Unknown Source)
Unknown.Vl(Unknown Source)
Unknown.Hu(Unknown Source)
Unknown.Ku(Unknown Source)
Unknown.ju(Unknown Source)
Unknown.h6(Unknown Source)
Unknown.As(Unknown Source)
Unknown.j6(Unknown Source)
Unknown.u6(Unknown Source)
Unknown.L3(Unknown Source)
Unknown.k5(Unknown Source)
Unknown.hn(Unknown Source)
Unknown.mn(Unknown Source)
Unknown.ln/<(Unknown Source)
Unknown.anonymous(Unknown Source)

How can I make this show the actual stack trace like the old GWT style?

quarks
  • 33,478
  • 73
  • 290
  • 513
  • See http://stackoverflow.com/q/24264925/181497. As of 2.7, it seems it can't be done (WTF, I know). It helps to use `GWT.log`, but the stacktrace is nowhere near as readable and usable as it should be. – Igor Klimer Jan 04 '15 at 15:39
  • With that said, the stack trace in the question has is obfuscated, which means it isn't from super dev mode - SDM only generates PRETTY code, so stack traces are at least *slightly* less useless than that... – Colin Alworth Jan 05 '15 at 01:03

1 Answers1

4

This worked for me, keep in mind it's not perfect but it will give you the file and line numbers in your stack trace. Yes this works with gwt 2.7 and super dev mode. You need to add this to your *.gwt.xml file. You may want to turn this off for production because it adds quite a bit of code bloat but makes debugging much much simpler.

<set-property name="compiler.stackMode" value="emulated" />
<set-configuration-property name="compiler.emulatedStack.recordFileNames"
value="true" />
<set-configuration-property name="compiler.emulatedStack.recordLineNumbers"
value="true" />
Chris Hinshaw
  • 6,967
  • 2
  • 39
  • 65
  • Thanks Chris. For me, after setting the properties, restarting the GWT server (dev mode) and reloading the web page, the client stack traces contained class names and line numbers. Still obfuscated, but the line numbers and class names are very helpful. – Paul Jowett Feb 13 '16 at 02:20
  • @jowierun Yeah the line numbers and class names has been the best I have gotten with SuperDevMode. I have gotten comfortable with it though and do incremental refreshes so it makes it easier to find problems early. – Chris Hinshaw Feb 13 '16 at 02:30
  • This helped me find my problem however the stack trace I got was wrong (?!). I needed to turn on the code server (superdevmode) to get a useful stack trace (including recognisable method names). – Peter L Dec 29 '16 at 00:51