예제 #1
0
        protected void HandleException(Exception exception, CircuitState state)
        {
            if (ExceptionFilters.Any(filter => filter(exception)))
            {
                return;
            }

            if (ExcludedExceptions == null || !ExcludedExceptions.Contains(exception.GetType()))
            {
                state.ResetTime = DateTime.UtcNow.Add(Timeout);
                state.Increment();
                if (state.Position == CircuitPosition.HalfOpen || state.CurrentIteration >= Threshold)
                {
                    state.Position = CircuitPosition.Open;
                }

                Logger?.Invoke(exception.Message);
            }
        }
예제 #2
0
 /// <summary>
 ///     Restricts the application of this policy to all exceptions but the specified type. It is possible to
 ///     combine multiple calls to <c>ApplyTo</c> and <c>Exclude</c>.
 /// </summary>
 /// <param name="exceptionType">
 ///     The type of the exception to be ignored.
 /// </param>
 /// <returns>
 ///     The <see cref="ErrorPolicyBase" /> so that additional calls can be chained.
 /// </returns>
 public ErrorPolicyBase Exclude(Type exceptionType)
 {
     ExcludedExceptions.Add(exceptionType);
     return(this);
 }