TurboManage

David Chandler's Journal of Java Web and Mobile Development

  • David M. Chandler


    Web app developer since 1994 and Google Cloud Platform Instructor now residing in Colorado. Besides tech, I enjoy landscape photography and share my work at ColoradoPhoto.gallery.

  • Subscribe

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 224 other subscribers
  • Sleepless Nights…

    December 2009
    S M T W T F S
     12345
    6789101112
    13141516171819
    20212223242526
    2728293031  
  • Blog Stats

    • 1,040,365 hits

Quick note on using gwt-presenter’s ActionException

Posted by David Chandler on December 9, 2009

It seems that the best way to use gwt-presenter‘s ActionException is to extend it, as exception chaining using ActionException does not appear to work. Here’s a working example:

package com.roa.common.exception;

import net.customware.gwt.dispatch.shared.ActionException;

public class UserNotLoggedInException extends ActionException
{
	private String loginUrl;

	// Required for GWT-RPC!
	private UserNotLoggedInException()
	{
		super();
	}

	public UserNotLoggedInException(String loginUrl)
	{
		super();
		this.loginUrl = loginUrl;
	}

	public String getLoginUrl()
	{
		return loginUrl;
	}
}

Extending ActionException is nice because all your handler execute methods already declare it. And this way, in client code, you can use instanceof in your exception handlers without the need for getCause(), checking for null, etc.

Thanks to the Apache Hupa mail project for a similar example (InvalidSessionException) that helped me see the light on this! While you’re checking out Hupa, have a look at the HupaCallback class, too. Pretty nifty way to achieve centralized error handling on the client combined with gwt-presenter’s DisplayCallback class.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

 
%d bloggers like this: