Skip to content

Commit

Permalink
Fixed error handling in RequestExtensions minio#1041
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
holterbades committed Apr 18, 2024
1 parent 4895be4 commit 95d4add
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Minio/RequestExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.CodeAnalysis;
using System.Net;
using Minio.Credentials;
using Minio.DataModel;
Expand Down Expand Up @@ -126,8 +126,6 @@ await requestMessageBuilder.ResponseWriter(responseResult.ContentStream, cancell
request.Method == HttpMethod.Get)
responseResult.Exception = new MissingObjectLockConfigurationException();
}

return responseResult;
}
catch (Exception ex) when (ex is not (OperationCanceledException or
ObjectNotFoundException))
Expand All @@ -141,6 +139,9 @@ await requestMessageBuilder.ResponseWriter(responseResult.ContentStream, cancell
responseResult = new ResponseResult(request, ex);
return responseResult;
}

minioClient.HandleIfErrorResponse(responseResult, errorHandlers, startTime);
return responseResult;
}

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

if (response.Exception is null)
if (response.Exception is not null)
throw response.Exception;

if (handlers.Any())
Expand Down

0 comments on commit 95d4add

Please sign in to comment.