You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
thrownewInvalidOperationException($"You have executed the generic .Execute<{nameof(TResult)}> method on a non-generic {nameof(FallbackPolicy)}. A non-generic {nameof(FallbackPolicy)} only defines a fallback action which returns void; it can never return a substitute {nameof(TResult)} value. To use {nameof(FallbackPolicy)} to provide fallback {nameof(TResult)} values you must define a generic fallback policy {nameof(FallbackPolicy)}<{nameof(TResult)}>. For example, define the policy as Policy<{nameof(TResult)}>.Handle<Whatever>.Fallback<{nameof(TResult)}>(/* some {nameof(TResult)} value or Func<..., {nameof(TResult)}> */);");
Copy file name to clipboardExpand all lines: src/Polly.Shared/Fallback/FallbackPolicyAsync.cs
+17Lines changed: 17 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,6 @@
1
1
usingSystem;
2
2
usingSystem.Collections.Generic;
3
+
usingSystem.Diagnostics;
3
4
usingSystem.Threading;
4
5
usingSystem.Threading.Tasks;
5
6
@@ -11,6 +12,22 @@ internal FallbackPolicy(Func<Func<Context, CancellationToken, Task>, Context, Ca
11
12
:base(asyncExceptionPolicy,exceptionPredicates)
12
13
{
13
14
}
15
+
16
+
/// <summary>
17
+
/// Executes the specified asynchronous action within the policy and returns the result.
18
+
/// </summary>
19
+
/// <typeparam name="TResult">The type of the result.</typeparam>
20
+
/// <param name="action">The action to perform.</param>
21
+
/// <param name="context">Context data that is passed to the exception policy.</param>
22
+
/// <param name="continueOnCapturedContext">Whether to continue on a captured synchronization context.</param>
23
+
/// <param name="cancellationToken">A cancellation token which can be used to cancel the action. When a retry policy is in use, also cancels any further retries.</param>
24
+
/// <returns>The value returned by the action</returns>
25
+
/// <exception cref="System.InvalidOperationException">Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods.</exception>
thrownewInvalidOperationException($"You have executed the generic .Execute<{nameof(TResult)}> method on a non-generic {nameof(FallbackPolicy)}. A non-generic {nameof(FallbackPolicy)} only defines a fallback action which returns void; it can never return a substitute {nameof(TResult)} value. To use {nameof(FallbackPolicy)} to provide fallback {nameof(TResult)} values you must define a generic fallback policy {nameof(FallbackPolicy)}<{nameof(TResult)}>. For example, define the policy as Policy<{nameof(TResult)}>.Handle<Whatever>.Fallback<{nameof(TResult)}>(/* some {nameof(TResult)} value or Func<..., {nameof(TResult)}> */);");
0 commit comments