Skip to content

Commit 22ec019

Browse files
committed
rely on ErrorCause ToString for the messsage
1 parent c9bfc4d commit 22ec019

File tree

5 files changed

+8
-5
lines changed

5 files changed

+8
-5
lines changed

src/Elasticsearch.Net/Responses/Special/BytesResponse.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ protected override bool TryGetServerErrorReason(out string reason)
2121
{
2222
reason = null;
2323
if (!this.TryGetServerError(out var serverError)) return false;
24-
reason = serverError?.Error?.Reason;
24+
reason = serverError?.Error?.ToString();
2525
return !reason.IsNullOrEmpty();
2626
}
2727
}

src/Elasticsearch.Net/Responses/Special/StringResponse.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ protected override bool TryGetServerErrorReason(out string reason)
2121
{
2222
reason = null;
2323
if (!this.TryGetServerError(out var serverError)) return false;
24-
reason = serverError?.Error?.Reason;
24+
reason = serverError?.Error?.ToString();
2525
return !reason.IsNullOrEmpty();
2626
}
2727
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ public ElasticsearchClientException CreateClientException<TResponse>(TResponse r
491491

492492
var exceptionMessage = innerException?.Message ?? $"Request failed to execute";
493493
if (response.TryGetServerErrorReason(out var reason))
494-
exceptionMessage += $". Error: {reason}";
494+
exceptionMessage += $". ServerError: {reason}";
495495

496496
var pipelineFailure = data.OnFailurePipelineFailure;
497497
if (pipelineExceptions.HasAny())

src/Nest/CommonAbstractions/Response/ResponseBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public abstract class ResponseBase : IResponse
5757

5858
bool IElasticsearchResponse.TryGetServerErrorReason(out string reason)
5959
{
60-
reason = this.ServerError?.Error?.Reason;
60+
reason = this.ServerError?.Error?.ToString();
6161
return !reason.IsNullOrEmpty();
6262
}
6363

src/Tests/Reproduce/GithubIssue2985.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ public void CanReadSingleOrMultipleCommonGramsCommonWordsItem()
3434
);
3535
response.OriginalException.Should().NotBeNull().And.BeOfType<ElasticsearchClientException>();
3636
response.OriginalException.Message.Should()
37-
.Be("Request failed to execute. Error: Custom Analyzer [custom] failed to find filter under name [ascii_folding]");
37+
.StartWith("Request failed to execute. ServerError: ")
38+
.And.EndWith(
39+
"Type: illegal_argument_exception Reason: \"Custom Analyzer [custom] failed to find filter under name [ascii_folding]\""
40+
);
3841

3942
client.DeleteIndex(index);
4043
}

0 commit comments

Comments
 (0)