internal static TResult Execute <TResult>( Func <TResult> action, StrategyExceptions exceptions, int permittedRetryCount) { Exception firstCatched = null; for (int retryCount = 0; retryCount < permittedRetryCount; retryCount++) { try { return(action()); } catch (Exception ex) { firstCatched = firstCatched ?? ex; if (!exceptions.Contains(ex)) { throw; } } } throw firstCatched; }
internal static TResult Execute <TResult>( Func <TResult> action, StrategyExceptions exceptions, Func <TResult> fallbackAction) { try { return(action()); } catch (Exception ex) { if (!exceptions.Contains(ex)) { throw; } } return(fallbackAction()); }