<PackageReference Include="Polly" Version="4.2.2" />

CircuitBreakerEngine

using System; using System.Collections.Generic; using System.Linq; namespace Polly.CircuitBreaker { internal class CircuitBreakerEngine { internal static void Implementation(Action action, Context context, IEnumerable<ExceptionPredicate> shouldHandlePredicates, ICircuitController breakerController) { breakerController.OnActionPreExecute(); try { action(); breakerController.OnActionSuccess(context); } catch (Exception ex2) { Exception ex; Exception ex3 = ex = ex2; if (!shouldHandlePredicates.Any((ExceptionPredicate predicate) => predicate(ex))) throw; breakerController.OnActionFailure(ex, context); throw; } } } }