Thanks for the help, but nobody actually answered the question - ie, how
do I get the same page
as Tapestry generates sent to me. As stated I was already sending the
exception.
In any case, quite helpful, I have tweaked things using Bryans code
and come up with a
slighly more informative email exception report which will do for now.
Thanks,
Lindsay
Bryan Lewis wrote:
We do a similar thing, intercept activateExceptionPage() in a custom
Engine. You can get the same detailed trace that Tapestry displays:
ExceptionDescription[] edArray = new
ExceptionAnalyzer().analyze(cause);
// I'm omitting some code that checks for some trivial
exceptions that we'd
// we'd rather not get emails for. For example, we filter out
those where
// a user edits the URL to give a bad page name, or the ones
from that nasty
// hacker script that's looking for insecure Windows servers.
String to = [EMAIL PROTECTED];
String from = [EMAIL PROTECTED];
StringBuffer bodyBuf = new StringBuffer("For user ");
Visit visit = (Visit) getVisit();
if (visit != null) {
userName = visit.getUserName();
}
if (userName == null) {
userName = "<none>";
}
bodyBuf.append(userName);
for (int i = 0; i < edArray.length; i++) {
// Separator line between exceptions.
bodyBuf.append("\n-----\n");
ExceptionDescription ed = edArray[i];
bodyBuf.append("Type: " + ed.getExceptionClassName());
bodyBuf.append("\nMessage: " + ed.getMessage());
String[] traces = ed.getStackTrace();
if (traces != null && traces.length > 0) {
bodyBuf.append("\nFirst line of stack trace:\n ");
bodyBuf.append(traces[0]);
// Could append the whole trace.
}
else {
bodyBuf.append("\nNo stack trace.\n");
}
}
// This is our utility method that calls javax.mail methods.
Mail.sendEmail(from, to, subject, bodyBuf.toString());
}
Olve Hansen wrote:
tir, 17,.01.2006 kl. 21.07 +1100, skrev Lindsay Steele:
Is there anyway to get the exception page that tapestry displays on an
exception.
At the moment I intercept the exception and display a custom page to
the user. At the same time I have it send me a mail
that the exception occurred and use my own code to get the cause and
some of the exception. It is not as good as I hoped though.
I was just wondering if there was an easy way to get the detailed output
that Tapestry usually displays so that I can send that in an email
instead - giving me more information about the exception.
I just check if it is an ApplicationRuntimeException in my method (in my
engine class) :
protected void activateExceptionPage(IRequestCycle iRequestCycle,
ResponseOutputStream responseOutputStream,
Throwable throwable) throws
ServletException {
ExceptionRethrower exceptionRethrower = (ExceptionRethrower)
getBean("exceptionRethrower");
exceptionRethrower.checkForRethrow(throwable);
//If we get here, no exceptions was rethrown
if(throwable instanceof ApplicationRuntimeException){
ApplicationRuntimeException apr =
(ApplicationRuntimeException)
throwable;
log.error("Error message : "+apr.getMessage());
log.error("Error component : "+apr.getComponent());
log.error("Error location : "+apr.getLocation());
}
log.warn("\"Client-side\" exception occured:", throwable);
super.activateExceptionPage(iRequestCycle, responseOutputStream,
throwable);
}
Instead of logging it as done in method above, you could put the same
information into the email.
I guess it might even be possible to render the framework exception-page
and put the resulting html into an email as well, that would be even
better...
HTH
Olve
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]