Skip to content

Commit

Permalink
Update 'RetryPolicy' README Chapter and example in README for NuGet p…
Browse files Browse the repository at this point in the history
…ackage.
  • Loading branch information
kolan72 committed Dec 24, 2024
1 parent 30c2ce8 commit be5d25c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,11 @@ var retryResult = new RetryPolicy(2)
.WithErrorProcessorOf((Exception ex, ProcessingErrorInfo pi) =>
logger.LogError(ex,
"Policy processed exception on {Attempt} attempt:",
(pi as RetryProcessingErrorInfo).RetryCount + 1))
((RetryProcessingErrorInfo)pi).RetryCount + 1))
.Handle(ActionThatCanThrow);
```
where `RetryProcessingErrorInfo` is the subclass of `ProcessingErrorInfo`.
Note that within the `RetryPolicy`, the `RetryProcessingErrorInfo` class is always used instead of the base `ProcessingErrorInfo` class, so the direct cast is always successful.

You can also specify the delay time before next retry with `WithWait(TimeSpan)` method, or use one of the overloads with Func, returning TimeSpan, for example:
```csharp
Expand Down
2 changes: 1 addition & 1 deletion src/docs/NuGet.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var result =
.WithErrorProcessorOf((Exception ex, ProcessingErrorInfo pi) =>
logger.LogError(ex,
"Policy processed exception on {Attempt} attempt:",
(pi as RetryProcessingErrorInfo).RetryCount + 1))
((RetryProcessingErrorInfo)pi).RetryCount + 1))

.AddPolicyResultHandler((PolicyResult pr) =>
logger.LogWarning(
Expand Down

0 comments on commit be5d25c

Please sign in to comment.