Class FallbackSyntaxAsync
- Namespace
- Polly
- Assembly
- Polly.dll
Fluent API for defining a Fallback Policy.
public static class FallbackSyntaxAsync
- Inheritance
-
FallbackSyntaxAsync
- Inherited Members
Methods
FallbackAsync(PolicyBuilder, Func<Context, CancellationToken, Task>, Func<Exception, Context, Task>)
Builds a FallbackPolicy which provides a fallback action if the main execution fails. Executes the main delegate asynchronously, but if this throws a handled exception, first asynchronously calls onFallbackAsync
with details of the handled exception and execution context; then asynchronously calls fallbackAction
.
public static FallbackPolicy FallbackAsync(this PolicyBuilder policyBuilder, Func<Context, CancellationToken, Task> fallbackAction, Func<Exception, Context, Task> onFallbackAsync)
Parameters
policyBuilder
PolicyBuilderThe policy builder.
fallbackAction
Func<Context, CancellationToken, Task>The fallback delegate.
onFallbackAsync
Func<Exception, Context, Task>The action to call asynchronously before invoking the fallback delegate.
Returns
- FallbackPolicy
The policy instance.
Exceptions
- ArgumentNullException
fallbackAction
- ArgumentNullException
onFallbackAsync
FallbackAsync(PolicyBuilder, Func<Exception, Context, CancellationToken, Task>, Func<Exception, Context, Task>)
Builds a FallbackPolicy which provides a fallback action if the main execution fails. Executes the main delegate asynchronously, but if this throws a handled exception, first asynchronously calls onFallbackAsync
with details of the handled exception and execution context; then asynchronously calls fallbackAction
.
public static FallbackPolicy FallbackAsync(this PolicyBuilder policyBuilder, Func<Exception, Context, CancellationToken, Task> fallbackAction, Func<Exception, Context, Task> onFallbackAsync)
Parameters
policyBuilder
PolicyBuilderThe policy builder.
fallbackAction
Func<Exception, Context, CancellationToken, Task>The fallback delegate.
onFallbackAsync
Func<Exception, Context, Task>The action to call asynchronously before invoking the fallback delegate.
Returns
- FallbackPolicy
The policy instance.
Exceptions
- ArgumentNullException
fallbackAction
- ArgumentNullException
onFallbackAsync
FallbackAsync(PolicyBuilder, Func<CancellationToken, Task>)
Builds a FallbackPolicy which provides a fallback action if the main execution fails. Executes the main delegate asynchronously, but if this throws a handled exception, asynchronously calls fallbackAction
.
public static FallbackPolicy FallbackAsync(this PolicyBuilder policyBuilder, Func<CancellationToken, Task> fallbackAction)
Parameters
policyBuilder
PolicyBuilderThe policy builder.
fallbackAction
Func<CancellationToken, Task>The fallback delegate.
Returns
- FallbackPolicy
The policy instance.
Exceptions
- ArgumentNullException
fallbackAction
FallbackAsync(PolicyBuilder, Func<CancellationToken, Task>, Func<Exception, Context, Task>)
Builds a FallbackPolicy which provides a fallback action if the main execution fails. Executes the main delegate asynchronously, but if this throws a handled exception, first asynchronously calls onFallbackAsync
with details of the handled exception and execution context; then asynchronously calls fallbackAction
.
[Obsolete("This overload is deprecated and will be removed in a future release. Prefer the overload in which both fallbackAction and onFallbackAsync take a Context input parameter.")]
public static FallbackPolicy FallbackAsync(this PolicyBuilder policyBuilder, Func<CancellationToken, Task> fallbackAction, Func<Exception, Context, Task> onFallbackAsync)
Parameters
policyBuilder
PolicyBuilderThe policy builder.
fallbackAction
Func<CancellationToken, Task>The fallback delegate.
onFallbackAsync
Func<Exception, Context, Task>The action to call asynchronously before invoking the fallback delegate.
Returns
- FallbackPolicy
The policy instance.
Exceptions
- ArgumentNullException
fallbackAction
- ArgumentNullException
onFallbackAsync
FallbackAsync(PolicyBuilder, Func<CancellationToken, Task>, Func<Exception, Task>)
Builds a FallbackPolicy which provides a fallback action if the main execution fails. Executes the main delegate asynchronously, but if this throws a handled exception, first asynchronously calls onFallbackAsync
with details of the handled exception; then asynchronously calls fallbackAction
.
public static FallbackPolicy FallbackAsync(this PolicyBuilder policyBuilder, Func<CancellationToken, Task> fallbackAction, Func<Exception, Task> onFallbackAsync)
Parameters
policyBuilder
PolicyBuilderThe policy builder.
fallbackAction
Func<CancellationToken, Task>The fallback delegate.
onFallbackAsync
Func<Exception, Task>The action to call asynchronously before invoking the fallback delegate.
Returns
- FallbackPolicy
The policy instance.
Exceptions
- ArgumentNullException
fallbackAction
- ArgumentNullException
onFallbackAsync