<PackageReference Include="Polly.Core" Version="8.3.1" />

FaultGenerator

public sealed class FaultGenerator
A generator for creating faults (exceptions) using registered delegate functions.
public FaultGenerator()

Initializes a new instance of the FaultGenerator class.

Provides an implicit conversion from FaultGenerator to a delegate compatible with FaultGenerator.

public FaultGenerator AddException(Func<Exception> generator, int weight = 100)

Registers an exception generator delegate.

public FaultGenerator AddException(Func<ResilienceContext, Exception> generator, int weight = 100)

Registers an exception generator delegate that accepts a ResilienceContext.

public FaultGenerator AddException<TException>(int weight = 100) where TException : Exception

Registers an exception generator for a specific exception type, using the default constructor of that exception.