{
String msg = ex.getMessage();
String contextAwareLocation = null;
if (ex instanceof ContextAware)
{
ContextAware caex = (ContextAware) ex;
contextAwareLocation = caex.getLocation().toString() + " " +
caex.getQName() + "=\"" +
caex.getExpressionString() + "\"";
}
while (ex.getCause() != null)
{
ex = ex.getCause();
if (ex instanceof ContextAware)
{
ContextAware caex = (ContextAware) ex;
contextAwareLocation = caex.getLocation().toString() + " " +
caex.getQName() + "=\"" +
caex.getExpressionString() + "\"";
}
if (ex.getMessage() != null)
{
msg = ex.getMessage();
}