private async Task RetryAsync(Exception exception, bool async)
            {
                if (!_responseClassifier.IsRetriableException(exception))
                {
                    ExceptionDispatchInfo.Capture(exception).Throw();
                }

                if (_exceptions == null)
                {
                    _exceptions = new List <Exception>();
                }

                _exceptions.Add(exception);

                _retryCount++;

                if (_retryCount > _maxRetries)
                {
                    throw new AggregateException($"Retry failed after {_retryCount} tries", _exceptions);
                }

                _currentStream = EnsureStream(async ? (await _asyncStreamFactory(_position).ConfigureAwait(false)) : _streamFactory(_position));
            }
        public void DoesntRetryRequestFailedExceptionsWithStatusCode()
        {
            var classifier = new ResponseClassifier();

            Assert.False(classifier.IsRetriableException(new RequestFailedException(500, "IO Exception")));
        }
        public void RetriesRequestFailedExceptionsWithoutCode()
        {
            var classifier = new ResponseClassifier();

            Assert.True(classifier.IsRetriableException(new RequestFailedException(0, "IO Exception")));
        }
Esempio n. 4
0
 public override bool IsRetriableException(Exception exception)
 {
     return(_inner.IsRetriableException(exception));
 }