Skip to content

Commit 01ca010

Browse files
committed
do not snoop ApiCall from response but rely on it being passed to CreateClientException, it could come from a nested exception
1 parent 22ec019 commit 01ca010

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

src/Elasticsearch.Net/Transport/Pipeline/IRequestPipeline.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void BadResponse<TResponse>(ref TResponse response, IApiCallDetails callDetails,
5353

5454
void AuditCancellationRequested();
5555

56-
ElasticsearchClientException CreateClientException<TResponse>(TResponse response, RequestData data, List<PipelineException> seenExceptions)
56+
ElasticsearchClientException CreateClientException<TResponse>(TResponse response, IApiCallDetails callDetails, RequestData data, List<PipelineException> seenExceptions)
5757
where TResponse : class, IElasticsearchResponse, new();
5858
}
5959
}

src/Elasticsearch.Net/Transport/Pipeline/RequestPipeline.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,15 +482,16 @@ public void BadResponse<TResponse>(ref TResponse response, IApiCallDetails callD
482482
response.ApiCall.AuditTrail = this.AuditTrail;
483483
}
484484

485-
public ElasticsearchClientException CreateClientException<TResponse>(TResponse response, RequestData data, List<PipelineException> pipelineExceptions)
485+
public ElasticsearchClientException CreateClientException<TResponse>(
486+
TResponse response, IApiCallDetails callDetails, RequestData data, List<PipelineException> pipelineExceptions
487+
)
486488
where TResponse : class, IElasticsearchResponse, new()
487489
{
488-
var callDetails = response.ApiCall;
489490
if (callDetails.Success) return null;
490491
var innerException = pipelineExceptions.HasAny() ? new AggregateException(pipelineExceptions) : callDetails?.OriginalException;
491492

492493
var exceptionMessage = innerException?.Message ?? $"Request failed to execute";
493-
if (response.TryGetServerErrorReason(out var reason))
494+
if (response != null && response.TryGetServerErrorReason(out var reason))
494495
exceptionMessage += $". ServerError: {reason}";
495496

496497
var pipelineFailure = data.OnFailurePipelineFailure;

src/Elasticsearch.Net/Transport/Transport.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ private TResponse FinalizeResponse<TResponse>(RequestData requestData, IRequestP
171171
pipeline.ThrowNoNodesAttempted(requestData, seenExceptions);
172172

173173
var callDetails = GetMostRecentCallDetails(response, seenExceptions);
174-
var clientException = pipeline.CreateClientException(response, requestData, seenExceptions);
174+
var clientException = pipeline.CreateClientException(response, callDetails, requestData, seenExceptions);
175175

176176
if (response?.ApiCall == null)
177177
pipeline.BadResponse(ref response, callDetails, requestData, clientException);

0 commit comments

Comments
 (0)