protected bool PerformRescue(MethodInfo method, Exception ex)
{
context.LastException = (ex is TargetInvocationException) ? ex.InnerException : ex;
Type exceptionType = context.LastException.GetType();
RescueDescriptor att = null;
if (method != null)
{
ActionMetaDescriptor actionMeta = metaDescriptor.GetAction(method);
if (actionMeta.SkipRescue != null) return false;
att = GetRescueFor(actionMeta.Rescues, exceptionType);
}
if (att == null)
{
att = GetRescueFor(metaDescriptor.Rescues, exceptionType);
if (att == null) return false;
}
try
{
controller._selectedViewName = Path.Combine("rescues", att.ViewName);
ProcessView();
return true;
}
catch(Exception exception)
{
// In this situation, the rescue view could not be found
// So we're back to the default error exibition
if (logger.IsFatalEnabled)
{
logger.FatalFormat("Failed to process rescue view. View name " +
controller._selectedViewName, exception);
}
}
return false;
}