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.