Ah me. Step 1 should read:

1. Declare your RPC exception like so:

public class MyRPCException extends SerializableException {
    public MyRPCException() {
        super();
    }

    public MyRPCException(String message) {
        super(message);
    }

    //... other stuff?

}


On Nov 26, 1:32 am, Ravi M <[EMAIL PROTECTED]> wrote:
> Satya,
>
> The following should work.
>
> 1. Declare your RPC exception like so:
>
> public class MyRPCException extends SerializableException {
>     public TrackerRPCException() {
>         super();
>     }
>
>     public MyRPCException(String message) {
>         super(message);
>     }
>
>     //... other stuff?
>
> }
>
> 2. Declare your service method like so:
>
> public SomeReturnedObject myServiceMethod(...arguments...) throws
> MyRPCException;
>
> 3. Declare your async service method like so:
>
> public void myServiceMethod(...arguments..., AsyncCallback callback);
>
> 4. The server side implementation of your service method may be like
> so:
>
>     public SomeReturnedObject myServiceMethod(...arguments...) throws
> MyRPCException {
>         SomeReturnedObject ret = null;
>         try {
>             // Do stuff to "populate" ret. This stuff could
> potentially fail.
>         } catch (SomeNonGWTSerializableServerSideException e) {
>             throw new MyRPCException("This is an error message that
> may be appropriate to show in the UI: " + e.getMessage());
>         }
>         return ret;
>     }
>
> 5. In your AsyncCallback in the client:
>
>             public void onSuccess(Object result) {
>                 SomeReturnedObject foo = (SomeReturnedObject) result;
>                 // Happiness and tranquility reign supreme
>             };
>
>             public void onFailure(Throwable exception) {
>                 try {
>                     throw exception;
>                 } catch (MyRPCException e) {
>                     // Show the error message to the user,
>                     // or handle however you want to.
>                 }
>             };
>
> This should work, there may be some overkill in this though. All this
> is GWT 1.4.6x, I'm not sure if any of this has changed in 1.5.x.
>
> Hope this helps
>
> Ravi
>
> On Nov 26, 1:08 am, satya <[EMAIL PROTECTED]> wrote:
>
> > Thank you very much,
> > I guess i can return the String "IllegalDateRangeException" when
> > throwing that exception from my Service and check for that in my
> > onFailure class.
>
> > public void onFailure( Throwable caught )
> >                    {
> >                               if ( caught.getMessage().contains
> > ( "IllegalDateRangeException" ) )
>
> >                                     //handle my class.
> >                     }
>
> > Thnak you,
> > Satya
>
> > On Nov 25, 1:38 pm, "olivier nouguier" <[EMAIL PROTECTED]>
> > wrote:
>
> > > On Tue, Nov 25, 2008 at 8:14 PM, satya <[EMAIL PROTECTED]> wrote:
>
> > > > Also
>
> > > > when i call the actual method, does the exception get caught in the
> > > > failure method or in my catch method?
>
> > > > For example:
>
> > > > AsyncCallback callBack = new AsyncCallback() {
> > > >                    public void onFailure( Throwable caught )
> > > >                    {
> > > >                        //Is the exception caught here?????
> > > here !
> > > >                    }
>
> > > >                    public void onSuccess( Object result )
> > > >                    {
>
> > > >                   }
> > > > try
> > > >                {
> > > >                    createNewRuleService.createRule( screenType,
> > > > eventRuleForm, callBack );
> > > >                }
> > > >                catch ( IllegalDateRangeException e )
> > > >                {
> > > >                  ////  or the exception is caught here?
>
> > > >                }
>
> > > You should  notice the differences between RemoteInterface and its
> > > Asyn counter part:
> > > * return type: the asyn interface method doesn't have return value
> > > ===>  it will be pass as parameter  asynchronously in onSuccess
> > > callback.
> > > * exception: are not part of the async method  ===>  it will be pass
> > > as parameter  asynchronously in onFailure callback.
>
> > > > Thank you very much for your help. I appreciate it.
>
> > > > Satya
>
> > > > On Nov 25, 1:10 pm, satya <[EMAIL PROTECTED]> wrote:
> > > >> How do i specify in the service signature that this is GWT
> > > >> serializable?
>
> > > >> my method signature looks like:
> > > >>  public String create(Rule rule) throws IllegalDateRangeException;
>
> > > >> On Nov 23, 5:23 am, "olivier nouguier" <[EMAIL PROTECTED]>
> > > >> wrote:
>
> > > >> > On Sun, Nov 23, 2008 at 6:58 AM, satya <[EMAIL PROTECTED]> wrote:
>
> > > >> > > Hi,
>
> > > >> > > Can i pass exceptions between client and server.
> > > >> > > Can i have an RPC serice with method that throw an user defined
> > > >> > > exception and handle that exception in the client side?
>
> > > >> > Yes as long as your exeption is declared in the Service Signature (to
> > > >> > be declared as "GWT serialisable").
>
> > > >> > > I created an userdefined exception:
> > > >> > > ------------------------------------------------------
> > > >> > > public class IllegalDateRangeException extends 
> > > >> > > SerializationException
> > > >> > > implements IsSerializable
> > > >> > > {
> > > >> > >    private String errorMessage = null;
>
> > > >> > >    public IllegalDateRangeException ( String error )
> > > >> > >    {
> > > >> > >        errorMessage = error;
> > > >> > >    }
>
> > > >> > >    public String toString()
> > > >> > >    {
> > > >> > >        return "Exception occurred: " + errorMessage;
> > > >> > >    }
>
> > > >> > >    public String getErrorMessage()
> > > >> > >    {
> > > >> > >        return errorMessage;
> > > >> > >    }
>
> > > >> > >    public void setErrorMessage( String errorMessage )
> > > >> > >    {
> > > >> > >        this.errorMessage = errorMessage;
> > > >> > >    }
>
> > > >> > > }
>
> > > >> > > and my RPC method throws this exception:
> > > >> > > ------------------------------------------------
> > > >> > >    public String create(Rule rule) throws 
> > > >> > > IllegalDateRangeException;
>
> > > >> > > and i want to catch this exception in the client side and perform
> > > >> > > actions.
>
> > > >> > > But i get the following error from GWT:
> > > >> > > [ERROR] Type
> > > >> > > 'com.cerner.cwx.ruleswizard.client.IllegalDateRangeException' was 
> > > >> > > not
> > > >> > > serializable and has no concrete serializable subtypes
>
> > > >> > > Any suggestions?
> > > >> > > Any help on this is greatly appreciated.
>
> > > >> > > Thank you
> > > >> > > Satya
>
> > > >> > --
> > > >> > Si l'ignorance peut servir de consolation, elle n'en est pas moins 
> > > >> > illusoire.
>
> > > --
> > > Si l'ignorance peut servir de consolation, elle n'en est pas moins 
> > > illusoire.
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to