You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Ryan Owens <ry...@infoether.com> on 2005/03/08 21:20:03 UTC
Handling errors in custom engine.cleanupAfterRequest
I've got a custom Engine where I override setupForRequest and
cleanupAfterRequest to handle some resource init and cleanup.
I also override activateExceptionPage to logout the user if there is
one and take them to the custom error page.
Normally I rely on ApplicationRuntimeExceptions to get the above
behaviour, but it does not work when an error occurs in the
cleanupAfterRequest method.
After some logging and reading the AbstractEngine source, I see the
reason is that cleanupAfterRequest only handles Exceptions and cannot
activate the exception page since the output stream is already closed.
It should have been obvious to me by the method name that I was AFTER
the request, so of course I can't forward to a page at that point.
What I am currently doing is catching the ApplicationRuntimeException
in the cleanupAfterRequest method, logging out the user, invalidating
the session and logging the error. As far as I can tell, all
AbstractEngine does is catches the error and reports it (logs it). So I
don't bother rethrowing the error.
This arrangement works much better than what I had before because now I
can tell when an error happens because I am immediately logged out.
Otherwise the application still activates the new page and it looks
like everything went ok.
So the question is:
What is the preferred way of handling errors in Engine.
cleanupAfterRequest?
Is there some way to activate an Exception page from there even though
the output is flushed?
Thanks,
Ryan Owens
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org