Castle.MonoRail.Framework.ControllerLifecycleExecutor.GetRescueFor C# (CSharp) Method

GetRescueFor() protected method

Gets the rescue for the specified exception type.
protected GetRescueFor ( IList rescues, Type exceptionType ) : RescueDescriptor
rescues IList The rescues.
exceptionType System.Type Type of the exception.
return Castle.MonoRail.Framework.Internal.RescueDescriptor
		protected RescueDescriptor GetRescueFor(IList rescues, Type exceptionType)
		{
			if (rescues == null || rescues.Count == 0) return null;

			RescueDescriptor bestCandidate = null;

			foreach(RescueDescriptor rescue in rescues)
			{
				if (rescue.ExceptionType == exceptionType)
				{
					return rescue;
				}
				else if (rescue.ExceptionType != null &&
				         rescue.ExceptionType.IsAssignableFrom(exceptionType))
				{
					bestCandidate = rescue;
				}
			}

			return bestCandidate;
		}