Hi,

(... not really related)

Is there any reason why Action and DispatchAction handle exceptions
differently in Struts 1.1-B1 ?

eg. the Action does a stack trace, while the DispatchAction does not.


Regards,
Daniel

-----Original Message-----
From: Drew McAuliffe [mailto:[EMAIL PROTECTED]]
Sent: Saturday, July 20, 2002 3:03 AM
To: [EMAIL PROTECTED]
Subject: DispatchAction and declarative exception handling


I'm not sure if this is intended behavior, but I've found what looks to
me like a problem with the DispatchAction class. In the "dispatchMethod"
method, exceptions are trapped and when they occur, are usually
processed by a call to "response.sendError()". This appears to bypass
any exception handling that might be configured declaratively. For
instance, if I have a login method on a subclass of "DispatchAction",
and it throws an "AuthenticationException", the dispathMethod will see
that as an InvocationTargetException and make a call to
"response.sendError()". So no matter how I've configured exceptions in
struts-config, I'll always get an error.

I would think that for at least "InvocationTargetException", this should
not be the way the exception is handled. I've modified my subclass of
DispatchAction to override "dispatchMethod". In my override, I treat
"InvocationTargetException" differently than the other trapped
exceptions. Because you'd usually reach this exception if there was an
exception in the action method, it will usually be a business exception
and not a system exception. My override pulls the cause exception out
("getCause") and throws it, rather than calling "response.sendError()"
and returning null. As a result, I can throw business exceptions in my
dispatchAction subclass methods and configure how they are handled in
the struts-config file.

Does this sound right, or am I missing something in how the
DispatchAction is supposed to be used?


--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to