Exception error handling on the client-side

43 views
Skip to first unread message

icfantv

unread,
Jan 25, 2012, 11:16:13 AM1/25/12
to Google Web Toolkit
I was under the impression that I could use
GWT.UncaughtExceptionHandler and subsequently
GWT.setUncaughtExceptionHandler to catch uncaught exceptions in the
client. Basically, I'd like to display the stacktrace of any uncaught
exception in a dialog.

I had a bug in my code whereby a I was trying to iterate over a null
list and it should have thrown a NullPointerException, but my error
handling code was never triggered. However, if I add a button with a
select handler that simply throws a new runtime exception, it works.

Anyone know what I might be doing wrong here or how to implement the
uncaught exception handler correctly? Thanks.

Ed

unread,
Jan 25, 2012, 2:18:58 PM1/25/12
to google-we...@googlegroups.com
Make sure to run the code after  calling "GWT.setUncaughtExceptionHandler" deferred (Scheduler.scheduleDeferred). Only then the exception handler is "set" correctly and can be used.

icfantv

unread,
Jan 25, 2012, 4:12:09 PM1/25/12
to Google Web Toolkit
I'm sorry, I don't exactly follow. I have it set as the first line in
my EntryPoint's onModuleLoad() method. Is this not the right place?

Ed Bras

unread,
Jan 25, 2012, 4:28:38 PM1/25/12
to google-we...@googlegroups.com
Yes that's correct, but it's all about what you do after that call.
For some reason you need the code after to be executed Deferred such that the changes take effect.
See:  http://code.google.com/webtoolkit/doc/1.6/DevGuideCodingBasics.html , the section about the DeferredCommand class.




--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.


icfantv

unread,
Jan 25, 2012, 4:41:50 PM1/25/12
to Google Web Toolkit
Ahhhh. I understand. In my case, I'm pretty sure I've waited long
enough as the exception handler is registered before any of the main
entry page is constructed. I have to manually click through a menu
system to get to a grid generation option that would have triggered
the NPE. I *think* in this case, that the exception handler would
have registered, no?
Reply all
Reply to author
Forward
0 new messages