//
// Look up the ExceptionConfig that's associated with this Throwable.
//
Class exClass = ex.getClass();
ExceptionConfig exceptionConfig = null;
if ( actionMapping != null )
{
exceptionConfig = actionMapping.findException( exClass );
}
else
{
// If the mapping was null (i.e., the exception happened before we got the action mapping), look for the
// exception only in the module config.
exceptionConfig = getExceptionConfig(exClass, moduleConfig);
}
//
// If there was no applicable exception handler in the current ModuleConfig, look in a shared flow's module.
//
if ( exceptionConfig == null )
{
FlowController fallbackFC =
getFallbackFlowController( flowController, exClass, request, response, getServletContext() );
if ( fallbackFC != null )
{
flowController = fallbackFC;
context = new FlowControllerHandlerContext( request, response, flowController );
moduleConfig = flowController.theModuleConfig();
exceptionConfig = getExceptionConfig( exClass, moduleConfig );
if ( exceptionConfig != null )
{
// This is the module that will be handling the exception. Ensure that its message resources are
// initialized.
assert request instanceof HttpServletRequest : request.getClass().getName();
InternalUtils.selectModule( moduleConfig.getPrefix(), ( HttpServletRequest ) request,
getServletContext() );
rw.setCurrentFlowController( flowController );
}
}
actionMapping = null; // This action mapping isn't relevant if we found the exception elsewhere.
}
if ( exceptionConfig != null )
{
if ( _log.isDebugEnabled() )
{
_log.debug( "Found exception-config for exception " + exClass.getName()
+ ": handler=" + exceptionConfig.getHandler() + ", path=" + exceptionConfig.getPath() );
}
// If this is a delegating exception handler, use its *delegate's* ModuleConfig.
if (exceptionConfig instanceof DelegatingExceptionConfig) {
moduleConfig = ((DelegatingExceptionConfig) exceptionConfig).getDelegateModuleConfig(getServletContext());