Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Using UncaughtExceptionHandler in SmartGWT application

    Hello,
    My goal is to have a unique place where I can handle unhandled exception. I did try GWT.setUncaughtExceptionHandler but it doesn't work as I would expect. In hosted-mode, I can see the stack trace of my exception in Eclipse console window (which is maybe the good behavior):

    Uncaught JavaScript exception [java.lang.NullPointerException: test
    [... and the stack ...]

    However, in web-mode, the onUncaughtException method of the UncaughtExceptionHandler object is never called. Is there something I understand wrong about this? Is there any other way to achieve this?

    Here is my simplified code:

    Code:
    public class MyApp implements EntryPoint {
    	public void onModuleLoad()
    	{
    		GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler()
    		{
    			public void onUncaughtException(Throwable e)
    			{
    				Window.alert("Blabla: " + e);
    			}			
    		});
    		
    	    // Use deferred command to catch initialization exceptions
    	    DeferredCommand.addCommand(new Command() {
    	      public void execute() {
    	        onModuleLoadReal();
    	      }
    	    });		
    	}	
    	
    	private void onModuleLoadReal()
    	{
    		// I do all the init stuff here, if I throw an exception, the onUncaughtException is called properly. However, if an exception is thrown somewhere else in my application, the onUncaughtException is never called in web-mode.
    	}
    }

    #2
    This should now be fixed. See details here. Note that you'll need to upgrade to GWT 2.0 if you haven't already done so.

    Sanjiv

    Comment


      #3
      I am having the same problem. I am using:
      GWT 2.1.1
      SmartGWT 2.4 EE.

      I have this method :

      Code:
      public void onModuleLoad() {
          	
          	GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() {
      			public void onUncaughtException(Throwable e) {
      				.. here I show a popup window with an error message
                          }
      		});
      For testing, I am creating an ArithmeticException: int x = 3/0;

      When debugging with eclipse, I get the popup window showing the error.
      But when I compile and run then, I don't get anything.

      What am I doing wrong?

      Comment


        #4
        Any ideas ?

        Comment

        Working...
        X