}
final String msg = "Request error encountered while processing portal request: "+t.getMessage();
log.error(msg, t);
// try to unwind and see if an Exception was thrown containing a RequestDiagnostics
RequestDiagnostics rd = null;
Throwable e = t;
do
{
if (e instanceof RequestDiagnosticsHolder && ((RequestDiagnosticsHolder)e).getRequestDiagnostics() != null)
{
rd = ((RequestDiagnosticsHolder)e).getRequestDiagnostics();
break;
}
e = e.getCause();
}
while (e != null);
if (rd == null)
{
rd = RequestDiagnosticsFactory.newRequestDiagnostics();
}
RequestDiagnosticsFactory.fillInRequestContext(rd, req, context, t);
rd.logAsError();
req.getSession(true).setAttribute(PortalReservedParameters.REQUEST_DIAGNOSTICS_ATTRIBUTE, rd);
res.sendRedirect(req.getContextPath() + errorHandlerPath);
}