From 9a052c82e07a6fa94e6c8e76bd6bd95b525b9bac Mon Sep 17 00:00:00 2001 From: Kevin Yu Date: Wed, 29 May 2024 12:07:48 -0700 Subject: [PATCH] Improve error message by handling caused_by.reason --- pkg/opensearch/response_parser.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/opensearch/response_parser.go b/pkg/opensearch/response_parser.go index f23c57f3..4770f37c 100644 --- a/pkg/opensearch/response_parser.go +++ b/pkg/opensearch/response_parser.go @@ -1342,12 +1342,15 @@ func getErrorFromOpenSearchResponse(response *client.SearchResponse) error { json := utils.NewJsonFromAny(response.Error) reason := json.Get("reason").MustString() rootCauseReason := json.Get("root_cause").GetIndex(0).Get("reason").MustString() + causedByReason := json.Get("caused_by").Get("reason").MustString() switch { case rootCauseReason != "": err = errors.New(rootCauseReason) case reason != "": err = errors.New(reason) + case causedByReason != "": + err = errors.New(causedByReason) default: err = errors.New("unknown OpenSearch error response") }