diff --git a/src/Middleware/RetryHandler.cs b/src/Middleware/RetryHandler.cs index c20df77..4087f6e 100644 --- a/src/Middleware/RetryHandler.cs +++ b/src/Middleware/RetryHandler.cs @@ -234,7 +234,7 @@ private static bool ShouldRetry(HttpStatusCode statusCode) private static async Task GetInnerException(HttpResponseMessage response, CancellationToken cancellationToken) { var httpStatusCode = response.StatusCode; - var errorMessage = "The response has not content."; + string? errorMessage = null; // Drain response content to free connections. Need to perform this // before retry attempt and before the TooManyRetries ServiceException. @@ -248,7 +248,7 @@ private static async Task GetInnerException(HttpResponseMessage respo errorMessage = GetStringFromContent(responseContent); } - return new Exception($"HTTP request failed with status code: {httpStatusCode}. Error Message: {errorMessage}"); + return new Exception($"HTTP request failed with status code: {httpStatusCode}.{errorMessage}"); } private static string GetStringFromContent(byte[] content)