You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Yves Sy <yv...@gmail.com> on 2005/03/08 07:44:32 UTC
Exception Logging
Hi,
I created my own exception page and would like to log the exception so
I can send it to myself via an smtp appender. Right now I extended
both
org.apache.tapestry.pages.Exception and
org.apache.tapestry.util.exception.ExceptionAnalyzer
and put the log statements in ExceptionAnalyzer.analyze().
Is there a more standard way of doing this?
Br,
-Yves-
--
A bus station is where a bus stops. A train station is where a train
stops. On my desk I have a work station...
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Exception Logging
Posted by Yves Sy <yv...@gmail.com>.
Ahhh! That's what I'm looking for! I knew it felt awkward doing it the
way i did it.
Thanks! :o)
On Tue, 8 Mar 2005 09:52:51 -0500, Bryan Lewis <br...@maine.rr.com> wrote:
> I think it would be more typical to override Engine.activateExceptionPage().
> It's fairly common to have a custom Engine class anyway. Here's the basics
> of what's been working well for us:
>
> protected void activateExceptionPage(IRequestCycle cycle,
> ResponseOutputStream output,
> Throwable cause)
> throws ServletException
> {
> ExceptionDescription[] edArray = new
> ExceptionAnalyzer().analyze(cause);
>
> // Always write the trace to the log, even if about to show the
> // exception page. This will write the details to STDERR
> // where log4j will catch it.
> reportException("activateExceptionPage()", cause);
>
> if (/* running on a development machine */) {
> // Show the standard Tapestry exception page.
> super.activateExceptionPage(cycle, output, cause);
> return;
> }
>
> // We're not on a dev machine. Send an email to us developers.
> sendExceptionEmail(edArray);
>
> // Present a friendly-looking page to the user.
> String pageName = "BFE";
> try {
> cycle.activate(pageName);
> renderResponse(cycle, output);
> }
> catch (Throwable ex) {
> // This will happen if something prevents display of the error
> // page, like a syntax error in that page's html.
> throw new ServletException(ex.getMessage(), ex);
> }
> }
>
> ----- Original Message -----
> From: "Yves Sy" <yv...@gmail.com>
> To: "Tapestry users" <ta...@jakarta.apache.org>
> Sent: Tuesday, March 08, 2005 1:44 AM
> Subject: Exception Logging
>
> > Hi,
> >
> > I created my own exception page and would like to log the exception so
> > I can send it to myself via an smtp appender. Right now I extended
> > both
> >
> > org.apache.tapestry.pages.Exception and
> > org.apache.tapestry.util.exception.ExceptionAnalyzer
> >
> > and put the log statements in ExceptionAnalyzer.analyze().
> >
> > Is there a more standard way of doing this?
> >
> > Br,
> > -Yves-
> >
> > --
> > A bus station is where a bus stops. A train station is where a train
> > stops. On my desk I have a work station...
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
--
A bus station is where a bus stops. A train station is where a train
stops. On my desk I have a work station...
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Exception Logging
Posted by Bryan Lewis <br...@maine.rr.com>.
I think it would be more typical to override Engine.activateExceptionPage().
It's fairly common to have a custom Engine class anyway. Here's the basics
of what's been working well for us:
protected void activateExceptionPage(IRequestCycle cycle,
ResponseOutputStream output,
Throwable cause)
throws ServletException
{
ExceptionDescription[] edArray = new
ExceptionAnalyzer().analyze(cause);
// Always write the trace to the log, even if about to show the
// exception page. This will write the details to STDERR
// where log4j will catch it.
reportException("activateExceptionPage()", cause);
if (/* running on a development machine */) {
// Show the standard Tapestry exception page.
super.activateExceptionPage(cycle, output, cause);
return;
}
// We're not on a dev machine. Send an email to us developers.
sendExceptionEmail(edArray);
// Present a friendly-looking page to the user.
String pageName = "BFE";
try {
cycle.activate(pageName);
renderResponse(cycle, output);
}
catch (Throwable ex) {
// This will happen if something prevents display of the error
// page, like a syntax error in that page's html.
throw new ServletException(ex.getMessage(), ex);
}
}
----- Original Message -----
From: "Yves Sy" <yv...@gmail.com>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Tuesday, March 08, 2005 1:44 AM
Subject: Exception Logging
> Hi,
>
> I created my own exception page and would like to log the exception so
> I can send it to myself via an smtp appender. Right now I extended
> both
>
> org.apache.tapestry.pages.Exception and
> org.apache.tapestry.util.exception.ExceptionAnalyzer
>
> and put the log statements in ExceptionAnalyzer.analyze().
>
> Is there a more standard way of doing this?
>
> Br,
> -Yves-
>
> --
> A bus station is where a bus stops. A train station is where a train
> stops. On my desk I have a work station...
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org