Exactly. Then in your *.application file, put something like
<page name="Exception" specification-path="/ErrorPage.page" />
and make sure that page has the API that tapestry's internal exception
page has. To save you the trouble, here's tapestry's exception page class:
public abstract class Exception extends BasePage implements
PageDetachListener {
/** Transient property */
public abstract void setExceptions(ExceptionDescription[] exceptions);
public void setException(Throwable value) {
ExceptionAnalyzer analyzer = new ExceptionAnalyzer();
ExceptionDescription[] exceptions = analyzer.analyze(value);
setExceptions(exceptions);
}
}
I should mention that there are other gurus on this list who can
probably tell you how to make all this stuff log by properly configuring
hivemind. But if you want to play with the message, my code should suit
you.
-Steve
[EMAIL PROTECTED] wrote:
Thanks Steve.
So in Exception.html I could just have a
<span jwcid="@ExceptionDisplay" exceptions="ognl:exceptionDescription" />
?
Thanks,
Greg
-----Original Message-----
From: Steve Shucker [mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 27, 2006 11:04 AM
To: Tapestry users
Subject: Re: Custom exception page
Look at tapestry's ExceptionDisplay component source. It uses something
called an ExceptionAnalyzer and also displays the contents of the
ExceptionDescription.getProperties().
I've got a custom exception page that writes to log4j. Here's what I
use to get the text:
public void logException(Throwable value) {
ExceptionAnalyzer analyzer = new ExceptionAnalyzer();
ExceptionDescription[] exceptions = analyzer.analyze(value);
setExceptions(exceptions);
StringBuffer text = new StringBuffer();
for (ExceptionDescription exception : exceptions) {
text.append("Class: " + exception.getExceptionClassName() +
"\n");
text.append("Message: " + exception.getMessage() + "\n");
for (ExceptionProperty property : exception.getProperties()) {
text.append("Property: " + property.getName() + " = " +
property.getValue() + "\n");
}
}
String[] stack = exceptions[exceptions.length-1].getStackTrace();
for (String stackItem : stack) {
text.append(stackItem + "\n");
}
log.error(text.toString());
}
-Steve
[EMAIL PROTECTED] wrote:
Can anyone help me out with a snippet of code? On my Exception.html/.page I
have a simple @Insert with getError(). Here's my code, but it doesn't provide a
nice traceback :(
public String getError()
{
ExceptionDescription[] Errors = getExceptions();
String err = "";
for (int i = 0; i < Errors.length; i++)
err += Errors[i].getMessage() + "<br>";
return err;
}
Any ideas?
Thanks,
Greg
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]