Table of Contents

Class FallbackSyntax

Namespace
Polly
Assembly
Polly.dll

Fluent API for defining a Fallback Policy.

public static class FallbackSyntax
Inheritance
FallbackSyntax
Inherited Members

Methods

Fallback(PolicyBuilder, Action)

Builds a FallbackPolicy which provides a fallback action if the main execution fails. Executes the main delegate, but if this throws a handled exception, calls fallbackAction.

public static FallbackPolicy Fallback(this PolicyBuilder policyBuilder, Action fallbackAction)

Parameters

policyBuilder PolicyBuilder

The policy builder.

fallbackAction Action

The fallback action.

Returns

FallbackPolicy

The policy instance.

Exceptions

ArgumentNullException

fallbackAction

Fallback(PolicyBuilder, Action, Action<Exception, Context>)

Builds a FallbackPolicy which provides a fallback action if the main execution fails. Executes the main delegate, but if this throws a handled exception, first calls onFallback with details of the handled exception and the execution context; then calls fallbackAction.

[Obsolete("This overload is deprecated and will be removed in a future release. Prefer the overload in which both fallbackAction and onFallback take a Context input parameter.")]
public static FallbackPolicy Fallback(this PolicyBuilder policyBuilder, Action fallbackAction, Action<Exception, Context> onFallback)

Parameters

policyBuilder PolicyBuilder

The policy builder.

fallbackAction Action

The fallback action.

onFallback Action<Exception, Context>

The action to call before invoking the fallback delegate.

Returns

FallbackPolicy

The policy instance.

Exceptions

ArgumentNullException

fallbackAction

ArgumentNullException

onFallback

Fallback(PolicyBuilder, Action, Action<Exception>)

Builds a FallbackPolicy which provides a fallback action if the main execution fails. Executes the main delegate, but if this throws a handled exception, first calls onFallback with details of the handled exception; then calls fallbackAction.

public static FallbackPolicy Fallback(this PolicyBuilder policyBuilder, Action fallbackAction, Action<Exception> onFallback)

Parameters

policyBuilder PolicyBuilder

The policy builder.

fallbackAction Action

The fallback action.

onFallback Action<Exception>

The action to call before invoking the fallback delegate.

Returns

FallbackPolicy

The policy instance.

Exceptions

ArgumentNullException

fallbackAction

ArgumentNullException

onFallback

Fallback(PolicyBuilder, Action<Context, CancellationToken>, Action<Exception, Context>)

Builds a FallbackPolicy which provides a fallback action if the main execution fails. Executes the main delegate, but if this throws a handled exception, first calls onFallback with details of the handled exception and the execution context; then calls fallbackAction.

public static FallbackPolicy Fallback(this PolicyBuilder policyBuilder, Action<Context, CancellationToken> fallbackAction, Action<Exception, Context> onFallback)

Parameters

policyBuilder PolicyBuilder

The policy builder.

fallbackAction Action<Context, CancellationToken>

The fallback action.

onFallback Action<Exception, Context>

The action to call before invoking the fallback delegate.

Returns

FallbackPolicy

The policy instance.

Exceptions

ArgumentNullException

fallbackAction

ArgumentNullException

onFallback

Fallback(PolicyBuilder, Action<Context>, Action<Exception, Context>)

Builds a FallbackPolicy which provides a fallback action if the main execution fails. Executes the main delegate, but if this throws a handled exception, first calls onFallback with details of the handled exception and the execution context; then calls fallbackAction.

public static FallbackPolicy Fallback(this PolicyBuilder policyBuilder, Action<Context> fallbackAction, Action<Exception, Context> onFallback)

Parameters

policyBuilder PolicyBuilder

The policy builder.

fallbackAction Action<Context>

The fallback action.

onFallback Action<Exception, Context>

The action to call before invoking the fallback delegate.

Returns

FallbackPolicy

The policy instance.

Exceptions

ArgumentNullException

fallbackAction

ArgumentNullException

onFallback

Fallback(PolicyBuilder, Action<Exception, Context, CancellationToken>, Action<Exception, Context>)

Builds a FallbackPolicy which provides a fallback action if the main execution fails. Executes the main delegate, but if this throws a handled exception, first calls onFallback with details of the handled exception and the execution context; then calls fallbackAction.

public static FallbackPolicy Fallback(this PolicyBuilder policyBuilder, Action<Exception, Context, CancellationToken> fallbackAction, Action<Exception, Context> onFallback)

Parameters

policyBuilder PolicyBuilder

The policy builder.

fallbackAction Action<Exception, Context, CancellationToken>

The fallback action.

onFallback Action<Exception, Context>

The action to call before invoking the fallback delegate.

Returns

FallbackPolicy

The policy instance.

Exceptions

ArgumentNullException

fallbackAction

ArgumentNullException

onFallback

Fallback(PolicyBuilder, Action<CancellationToken>)

Builds a FallbackPolicy which provides a fallback action if the main execution fails. Executes the main delegate, but if this throws a handled exception, calls fallbackAction.

public static FallbackPolicy Fallback(this PolicyBuilder policyBuilder, Action<CancellationToken> fallbackAction)

Parameters

policyBuilder PolicyBuilder

The policy builder.

fallbackAction Action<CancellationToken>

The fallback action.

Returns

FallbackPolicy

The policy instance.

Exceptions

ArgumentNullException

fallbackAction

Fallback(PolicyBuilder, Action<CancellationToken>, Action<Exception, Context>)

Builds a FallbackPolicy which provides a fallback action if the main execution fails. Executes the main delegate, but if this throws a handled exception, first calls onFallback with details of the handled exception and the execution context; then calls fallbackAction.

[Obsolete("This overload is deprecated and will be removed in a future release. Prefer the overload in which both fallbackAction and onFallback take a Context input parameter.")]
public static FallbackPolicy Fallback(this PolicyBuilder policyBuilder, Action<CancellationToken> fallbackAction, Action<Exception, Context> onFallback)

Parameters

policyBuilder PolicyBuilder

The policy builder.

fallbackAction Action<CancellationToken>

The fallback action.

onFallback Action<Exception, Context>

The action to call before invoking the fallback delegate.

Returns

FallbackPolicy

The policy instance.

Exceptions

ArgumentNullException

fallbackAction

ArgumentNullException

onFallback

Fallback(PolicyBuilder, Action<CancellationToken>, Action<Exception>)

Builds a FallbackPolicy which provides a fallback action if the main execution fails. Executes the main delegate, but if this throws a handled exception, first calls onFallback with details of the handled exception; then calls fallbackAction.

public static FallbackPolicy Fallback(this PolicyBuilder policyBuilder, Action<CancellationToken> fallbackAction, Action<Exception> onFallback)

Parameters

policyBuilder PolicyBuilder

The policy builder.

fallbackAction Action<CancellationToken>

The fallback action.

onFallback Action<Exception>

The action to call before invoking the fallback delegate.

Returns

FallbackPolicy

The policy instance.

Exceptions

ArgumentNullException

fallbackAction

ArgumentNullException

onFallback