Quantcast
Channel: Active questions tagged retry-logic - Stack Overflow
Viewing all articles
Browse latest Browse all 950

How does Polly retry policies indicate when number of retries have been exceeded?

$
0
0

I have a call that uses a Policy.Handle<PollingResult>(...).WaitAndRetry(...).ExecuteAsync(...) call to wrap a polling operation.

Having spent the better part of half an hour reading the Polly documentation, I cannot seem to find any way for this call to tell me "Whoops, seems we used all the retries to no avail!"

Like, how do I do this:

var retryResultWithAllDetails = Policy    .Handle<PollingResult>(poll => poll.IsReady)    .WaitAndRetry(maxRetries, n => RetryIntervalCalculation(n))    .ExecuteAsyncWithAllTheNecessaryNittyGrittyDetailsAndFootnotes(() => SomePollingOperation());if (retryResultWithAllDetails.RanOutOfRetryAttempts)  throw new WeRanOutOfRetryAttemptsException("Oops!")

It seems strange that this isn't just readily avialable as a boolean flag somewhere in the documentation.

I am not interested in the exceptions or whether it failed or whatnot — I know how to handle exceptions thrown from within Polly. I am interested in whether it ran out of retry attempts so I can log an appropriate error. I hope that is clear.


Viewing all articles
Browse latest Browse all 950

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>