public static void logExceptionLocation(PrintWriter pw, Throwable exception)
{
if (null == pw)
pw = new PrintWriter(System.err, true);
SourceLocator locator = null;
Throwable cause = exception;
// Try to find the locator closest to the cause.
do
{
// Find the current locator, if one present
if(cause instanceof SAXParseException)
{
// A SAXSourceLocator is a Xalan helper class
// that implements both a SourceLocator and a SAX Locator
//@todo check that the new locator actually has
// as much or more information as the
// current one already does
locator = new SAXSourceLocator((SAXParseException)cause);
}
else if (cause instanceof TransformerException)
{
SourceLocator causeLocator = ((TransformerException)cause).getLocator();
if(null != causeLocator)
{
locator = causeLocator;
}
}