1

I added an UncaughtExceptionHandler with the following code:

 GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() { public void onUncaughtException(Throwable e) { StackTraceElement[] elements = e.getStackTrace(); String stackTrace = ""; for (int i = 0; i < elements.length; i++) { stackTrace += elements[i] + "\n"; } PlatformServices.instance().log().debug("caught unhandled exception: " + e + " ; Stack:\n" + stackTrace); } }); 

The problem is that only the function name of each StackTraceElement is valid. All other information is default, such as -1 for line number or unknown for class name.

I wonder if I am doing something wrong?

2 Answers 2

2

This information may be just unavailable during GWT app execution. Check core StackTraceElement.java class, method toString(). Value of lineNumber is printed out only in case if it is >= zero. And it's not impossible that it can be negative.

My tests with UncaughtExceptionHandler gave me exactly same results (no references to line numbers in runtime). When compiled in Obfuscated mode, I couldn't even get the filename, so the output looked like:

com.google.gwt.core.client.JavaScriptException: (TypeError): Cannot read property 'g' of null Unknown.iPb(Unknown Source) Unknown.gPb(Unknown Source) Unknown.npd(Unknown Source) ... 

Not really a solution, but at least you are not alone :).

Sign up to request clarification or add additional context in comments.

Comments

1

Try to set this in your module file

<set-property name="compiler.stackMode" value="emulated" /> 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.