Tuesday, June 29, 2010

Re: GWT.setUncaughtExceptionHandler not working

Dear Isaac,

Wonderful!. Your solution is working well.

Thanks a lot!.

-Moorsu

On Tue, Jun 29, 2010 at 8:32 PM, Isaac Truett <itruett@gmail.com> wrote:
Moorsu,

Sorry to leave you hanging on StackOverflow. I didn't see your code sample, as I've just explained over there.

This behavior is described in issue #1617. In a nutshell, you need to set the handler and then defer the rest of onModuleLoad to the next event cycle.

GWT.setUncaughtExceptionHandler(new ClientExceptionHandler());
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
startApplication(); // causes an exception
Window.alert("You won't see this");
}
});

Hope that helps.

- Isaac

On Tue, Jun 29, 2010 at 10:27 AM, moorsu <moorsu@gmail.com> wrote:
Hi,

I already posted this question to stackoverflow. Posting again
here since I did not get any working answer. Sorry for the
duplicate post.

I registered my custom
UncaughtExceptionHandler to catch
all the client/server side runtime exceptions. The
handler does not catch them, but simply sending it to
browser.

Did I my understood the
UncaughtExceptionHandler functionality
or any other issue?

-thanks
moorsu.

Here is my code.


// ------------ Class 1 -------------------------------

package mypackage;


import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;

public class MyEntryPoint implements EntryPoint {

    public void onModuleLoad() {
        GWT.setUncaughtExceptionHandler(new ClientExceptionHandler());
        startApplication();
    }

    private void startApplication() {
        Integer.parseInt("I_AM_NOT_A_NUMBER");
        // or any exception that results from server call
    }
}

// --------------- Class 2 -----------------------------

package mypackage;

import com.google.gwt.core.client.GWT;

public class ClientExceptionHandler implements GWT.UncaughtExceptionHandler {

    public void onUncaughtException(Throwable cause) {

        System.out.println(cause.getMessage());
    }
}

// --------------------------------------------------------------

--
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-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

--
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-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

--
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-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment