diff --git a/src/KubernetesClient/Kubernetes.cs b/src/KubernetesClient/Kubernetes.cs index 6b9972485..95fee7077 100644 --- a/src/KubernetesClient/Kubernetes.cs +++ b/src/KubernetesClient/Kubernetes.cs @@ -163,7 +163,6 @@ protected virtual async Task SendRequestRaw(string requestC if (!httpResponse.IsSuccessStatusCode) { string responseContent = null; - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", statusCode)); if (httpResponse.Content != null) { responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); @@ -173,6 +172,7 @@ protected virtual async Task SendRequestRaw(string requestC responseContent = string.Empty; } + var ex = new HttpOperationException($"Operation returned an invalid status code '{statusCode}', response body {responseContent}"); ex.Request = new HttpRequestMessageWrapper(httpRequest, requestContent); ex.Response = new HttpResponseMessageWrapper(httpResponse, responseContent); httpRequest.Dispose();