|
From: Matt S. <mat...@sp...> - 2006-07-24 14:00:23
|
Yeah, the response may already be screwed up, but there's still the
potential to log the error or email the sys admin. I implemented this
functionality in my app very easily as follows
public class ViewExceptionInterceptor extends HandlerInterceptorAdapter {
private static final Logger logger =
Logger.getLogger(ViewExceptionInterceptor.class);
public void afterCompletion(HttpServletRequest request,
HttpServletResponse response, Object handler, Exception ex) throws
Exception {
if (ex != null) {
logger.error("Error while rendering view", ex);
}
super.afterCompletion(request, response, handler, ex);
}
}
I just posted this on dev because I thought if there's ever a time to
reconsider the name for HandlerInterceptor it's now, since AFAIK the
interface is new in Spring 2, and Spring 2 hasn't technically been
released yet. RequestInterceptor or WebInterceptor might be a better name.
Matt
Juergen Hoeller wrote:
> Point taken, Matt.
>
> I'm not opposed to adding callback support for view exceptions. However, we
> can't get rid of the issue that a view exception will usually lead into a
> situation where we can't render a proper error page anymore, since we
> already sent part of the original response to the client...
>
> Juergen
>
>
> -----Original Message-----
> From: spr...@li...
> [mailto:spr...@li...] On Behalf
> Of Matt Sgarlata
> Sent: Friday, July 21, 2006 9:36 PM
> To: spr...@li...
> Subject: [Springframework-developer] HandlerInterceptor is a misleading name
>
> HandlerInterceptors actually intercept both handlers and views, whereas
> HandlerExceptionResolvers only resolve exceptions for handlers. Just wanted
> to point this out...
>
> Matt
>
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's
> Techsay panel and you'll get the chance to share your opinions on IT &
> business topics through brief surveys -- and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Springframework-developer mailing list
> Spr...@li...
> https://lists.sourceforge.net/lists/listinfo/springframework-developer
>
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys -- and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
|