Skip to content

Commit 95d4add

Browse files
committed
Fixed error handling in RequestExtensions #1041
Response error handling was unintentionally removed in a previous commit. Added it back to the `ExecuteTaskCoreAsync` method. Fixed `NullReferenceException`-bug in the `HandleIfErrorResponse` method - `throw response.Exception;` does not make sense if the exception is null.
1 parent 4895be4 commit 95d4add

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Minio/RequestExtensions.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Diagnostics.CodeAnalysis;
1+
using System.Diagnostics.CodeAnalysis;
22
using System.Net;
33
using Minio.Credentials;
44
using Minio.DataModel;
@@ -126,8 +126,6 @@ await requestMessageBuilder.ResponseWriter(responseResult.ContentStream, cancell
126126
request.Method == HttpMethod.Get)
127127
responseResult.Exception = new MissingObjectLockConfigurationException();
128128
}
129-
130-
return responseResult;
131129
}
132130
catch (Exception ex) when (ex is not (OperationCanceledException or
133131
ObjectNotFoundException))
@@ -141,6 +139,9 @@ await requestMessageBuilder.ResponseWriter(responseResult.ContentStream, cancell
141139
responseResult = new ResponseResult(request, ex);
142140
return responseResult;
143141
}
142+
143+
minioClient.HandleIfErrorResponse(responseResult, errorHandlers, startTime);
144+
return responseResult;
144145
}
145146

146147
private static Task<ResponseResult> ExecuteWithRetry(this IMinioClient minioClient,
@@ -369,7 +370,7 @@ private static void HandleIfErrorResponse(this IMinioClient minioClient, Respons
369370
minioClient.LogRequest(response.Request, response, (now - startTime).TotalMilliseconds);
370371
}
371372

372-
if (response.Exception is null)
373+
if (response.Exception is not null)
373374
throw response.Exception;
374375

375376
if (handlers.Any())

0 commit comments

Comments
 (0)