Пример #1
0
		/// <summary>
		/// Performs the rescue.
		/// </summary>
		/// <param name="action">The action (can be null in the case of dynamic actions).</param>
		/// <param name="actionException">The exception.</param>
		/// <returns></returns>
		protected virtual bool ProcessRescue(IExecutableAction action, Exception actionException)
		{
			if (action != null && action.ShouldSkipRescues)
			{
				return false;
			}

			Type exceptionType = actionException.GetType();

			RescueDescriptor desc = action != null ? action.GetRescueFor(exceptionType) : null;

			if (desc == null)
			{
				desc = GetControllerRescueFor(exceptionType);
			}

			if (desc != null)
			{
				try
				{
					if (desc.RescueController != null)
					{
						CreateAndProcessRescueController(desc, actionException);
					}
					else
					{
						context.SelectedViewName = Path.Combine("rescues", desc.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.Fatal("Failed to process rescue view. View name " +
						                   context.SelectedViewName, exception);
					}
				}
			}

			return false;
		}