/// <summary> /// Specifies the type of exception that this policy can handle with additional filters on this exception type. /// </summary> /// <typeparam name="TException">The type of the exception.</typeparam> /// <param name="policies"></param> /// <param name="exceptionPredicate">The exception predicate to filter the type of exception this policy can handle.</param> /// <returns>The PolicyBuilder instance.</returns> public static PolicyExpression OnException <TException>(this IHasRetryPolicies policies, Func <TException, bool> exceptionPredicate) where TException : Exception { var builder = Policy <IContinuation> .Handle(exceptionPredicate); return(new PolicyExpression(policies.Retries, builder)); }
public static void RequeueOn <T>(this IHasRetryPolicies policies, Func <T, bool> filter = null) where T : Exception { if (filter == null) { policies.Retries.Add(x => x.Handle <T>().Requeue()); } else { policies.Retries.Add(x => x.Handle(filter).Requeue()); } }
public override void SetUp() { _errorHandling = Context.State.Retrieve <IHasRetryPolicies>(); _errorHandling.Retries.Clear(); }
/// <summary> /// Specifies the type of exception that this policy can handle if found as an InnerException of a regular /// <see cref="Exception" />, or at any level of nesting within an <see cref="AggregateException" />. /// </summary> /// <typeparam name="TException">The type of the exception to handle.</typeparam> /// <returns>The PolicyBuilder instance, for fluent chaining.</returns> public static PolicyExpression HandleInner <TException>(this IHasRetryPolicies policies) where TException : Exception { var builder = Policy <IContinuation> .HandleInner <TException>(); return(new PolicyExpression(policies.Retries, builder)); }
/// <summary> /// Specifies the type of exception that this policy can handle with additional filters on this exception type. /// </summary> /// <param name="policies"></param> /// <param name="exceptionType">An exception type to match against</param> /// <returns>The PolicyBuilder instance.</returns> public static PolicyExpression OnExceptionOfType(this IHasRetryPolicies policies, Type exceptionType) { return(policies.OnException(e => e.GetType().CanBeCastTo(exceptionType))); }