<PackageReference Include="Polly" Version="8.0.0-alpha.3" />

ExceptionPredicates

public class ExceptionPredicates
using System; using System.Collections.Generic; using System.Linq; namespace Polly { public class ExceptionPredicates { private List<ExceptionPredicate> _predicates; public static readonly ExceptionPredicates None = new ExceptionPredicates(); internal void Add(ExceptionPredicate predicate) { if (_predicates == null) _predicates = new List<ExceptionPredicate>(); _predicates.Add(predicate); } public Exception FirstMatchOrDefault(Exception ex) { List<ExceptionPredicate> predicates = _predicates; if (predicates == null) return null; return (from predicate in predicates select predicate(ex)).FirstOrDefault((Exception e) => e != null); } } }