Title: RE: [jdjlist] Re: Comparing Exceptions

Why not just use the standard try/catch? It has a built-in instnaceof and it is much easier on the eyes.


try {
        //something that may throw exceptions here

} catch (InvalidCredentialsException ice) {
          // do something to display message.
} catch (SomeOtherException soe)
          // do something ELSE to display message.
} catch (Exception e) {
        //generic exception
}

-----Original Message-----
From: Cohan, Sean [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, September 24, 2002 5:44 AM
To: JDJList
Subject: [jdjlist] Re: Comparing Exceptions


Thanks for the quick response.

-----Original Message-----
From: James A. N. Stauffer [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, September 24, 2002 8:37 AM
To: JDJList
Subject: [jdjlist] Re: Comparing Exceptions


instanceof
if (errorMessage.getException() instanceof InvalidCredentialsException)


--- "Cohan, Sean" <[EMAIL PROTECTED]> wrote:
> I catch an exception and place it in an object returned to me Struts
> action
> class.  How can I see what this eception is in order to display the
> correct
> message to the user?
>
> The object containing the Exception is ErrorMessage which contains a
> getException method which returns an Exception object.  Do I use the
> equals
> method to compare the returned exception to it's Exception class like so:
>
>
> (ErrorMessage) errorMessage = (ErrorMessage)
> serviceResponse.getErrorMessage();
>                                
> if (errorMessage.getException().equals(InvalidCredentialsException)) {
>     // do something to display message.
> }
>
> Thanks.
>
>
> To change your JDJList options, please visit:
http://www.sys-con.com/java/list.cfm


=====
James Amos Nathaniel Stauffer
Stauffer_James
@yahoo.com
Spam food: [EMAIL PROTECTED]

__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com

To change your JDJList options, please visit:
http://www.sys-con.com/java/list.cfm

To change your JDJList options, please visit: http://www.sys-con.com/java/list.cfm

To change your JDJList options, please visit: http://www.sys-con.com/java/list.cfm

Reply via email to