As explained, the code doesn't make any sense to me. An Action is a
Java class, and it can't violate the rules of Java. The rules say that
an Exception thrown in a try block is handled by the closest catch
block. There's nothing Struts can do about that.
Though, Struts does have a declarative exception handling feature that
will branch to a "graceful error page" without embedding a try/catch
in every Action.
*
http://struts.apache.org/1.x/userGuide/building_controller.html#exception_handler
-Ted.
On 11/24/06, Mon Cab <[EMAIL PROTECTED]> wrote:
I have an action class with an execute method as follows
public ActionForward execute( ActionMapping mapping,
ActionForm form,
HttpServletRequest req,
HttpServletResponse res
)
throws Exception
{
try
{
Do something innocuous;
Foo foo = new FooWhichThrowsAnExceptionInConstructor();
}
catch (Exception e)
{
mapping.findForward("goto_graceful_error_page");
}
}
But instead of going to the graceful error page the user gets the HTTP
Status 500 - page and I see the following in the error log.
org.apache.struts.action.RequestProcessor - Unhandled Exception thrown:
class java.lang.Exception
I put debug println's around the code and found that execution stopped
immediately at the call to the foo constructor, and the catch block was
never entered.
I am not doing anything outside of the try block. Is this behaviour
standard in struts? Shouldn't I be going to my graceful error page?
Can anyone shed any light on this?
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]