Skip to content

Commit

Permalink
Fix typos in safe execution description & snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
peter.csala committed Sep 27, 2023
1 parent a9dfe5b commit b90a112
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
14 changes: 9 additions & 5 deletions docs/migration-v8.md
Original file line number Diff line number Diff line change
Expand Up @@ -598,13 +598,13 @@ For more details, refer to the [Resilience context](advanced/resilience-context.

## Migrating safe execution

In v7, the `ExecuteAndCapture(Async)` methods are considered the safe counterpart of the `Execute(Async)`.
In v7, the `ExecuteAndCapture{Async}` methods are considered the safe counterpart of the `Execute{Async}`.

The former does not throw exception in case of failure rather than wraps the outcome into a result object.
The former does not throw an exception in case of failure rather than wrap the outcome in a result object.

In v8, the `ExecuteOutcomeAsync` should be used to execute the to-be-decorated method in a safe way.
In v8, the `ExecuteOutcomeAsync` method should be used to execute the to-be-decorated method in a safe way.

### `ExecuteAndCapture(Async)` in V7
### `ExecuteAndCapture{Async}` in V7

<!-- snippet: migration-execute-v7 -->
```cs
Expand All @@ -620,13 +620,15 @@ PolicyResult<int> asyncPolicyResult = await asyncPolicy.ExecuteAndCaptureAsync(M
if (policyResult.Outcome == OutcomeType.Successful)
{
int result = policyResult.Result;

// Process result
}
else
{
Exception exception = policyResult.FinalException;
FaultType failtType = policyResult.FaultType!.Value;
ExceptionType exceptionType = policyResult.ExceptionType!.Value;

// Process failure
}

Expand Down Expand Up @@ -664,14 +666,16 @@ ResilienceContextPool.Shared.Return(context);
if (pipelineResult.Exception is null)
{
int result = pipelineResult.Result;

// Process result
}
else
{
Exception exception = pipelineResult.Exception;

// Process failure
// If needed then you can rethrow the exception
// If needed you can rethrow the exception
pipelineResult.ThrowIfException();
}

Expand Down
6 changes: 5 additions & 1 deletion src/Snippets/Docs/Migration.Execute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ public static async Task SafeExecute_V7()
if (policyResult.Outcome == OutcomeType.Successful)
{
int result = policyResult.Result;

// Process result
}
else
{
Exception exception = policyResult.FinalException;
FaultType failtType = policyResult.FaultType!.Value;
ExceptionType exceptionType = policyResult.ExceptionType!.Value;

// Process failure
}

Expand Down Expand Up @@ -64,14 +66,16 @@ public static async Task SafeExecute_V8()
if (pipelineResult.Exception is null)
{
int result = pipelineResult.Result;

// Process result
}
else
{
Exception exception = pipelineResult.Exception;

// Process failure

// If needed then you can rethrow the exception
// If needed you can rethrow the exception
pipelineResult.ThrowIfException();
}

Expand Down

0 comments on commit b90a112

Please sign in to comment.