Thanks Mike! I think I will be able to extract the pagename from my own
stack trace, and thus solve my problem.
Thanks again.
[EMAIL PROTECTED] wrote:
This is something I do to emulate Log4j. Examine the stack & find the
first entry that does not contain ExceptionInfo as a classname.
call displayInfo() in your catch statement, or call displayInfo()
whereever to track class, method, & line number.
note: this code is customized for this example, not taken verbatim from my
code....
- Mike Barber
class ExceptionInfo
{
public void displayInfo()
{
// setup stack info
Throwable t = new Throwable();
StackTraceElement[] stackElements = t.getStackTrace();
int line = 0;
for (int i=0; i<stackElements.length; i++)
{
StackTraceElement ste = stackElements[i];
String simpleClassName =
_extractSimpleClassName(stackElements[i].getClassName());
// the first line to NOT have this class's name is the
line we want
if (simpleClassName != null &&
!simpleClassName.equals("ExceptionInfo"))
{
line = i;
StackTraceElement steFirst = stackElements[line];
System.out.println(steFirst.toString());
break;
}
}
}
private String _extractSimpleClassName(String fullClassName)
{
if ((null == fullClassName) || ("".equals(fullClassName)))
return "";
int lastDot = fullClassName.lastIndexOf('.');
if (0 > lastDot)
return fullClassName;
return fullClassName.substring(++lastDot);
}
}
Martijn Hinten <[EMAIL PROTECTED]>
11/15/2005 01:42 PM
Please respond to
"Tapestry users" <[email protected]>
To
Tapestry users <[email protected]>
cc
Subject
How to get the name of the page that raised an exception?
I have overridden Tapestry's exceptionPresenter and provided my own
subclass of org.apache.tapestry.error.ExceptionPresenter. In it's
presentException method, is there any way to figure out the name of the
page that raised the exception? I would like to show the exception in a
friendly way, on the page that raised it.
I noticed that cycle.getPage().getPageName() does not return the name of
the current page.
Thanks for any hints.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
*Cumquat Information Technology*
De Dreef 19
3706 BR Zeist
T +31 (0)30 - 6940490
F +31 (0)10 - 6940499
http://www.cumquat.nl <http://www.cumquat.nl/>
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
M +31 6 22 384 318
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]