From 3c2bee5b60966638540046d838c1ee11f6cccc1b Mon Sep 17 00:00:00 2001 From: mickael-hc <86245626+mickael-hc@users.noreply.github.com> Date: Mon, 13 Mar 2023 17:25:13 -0400 Subject: [PATCH] Update error message for invalid api response (#52) * update error messages for invalid api responses Co-authored-by: Austin Gebauer <34121980+austingebauer@users.noreply.github.com> --- client.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client.go b/client.go index 245991e..bf7841f 100644 --- a/client.go +++ b/client.go @@ -237,7 +237,7 @@ func (c *Client) do(ctx context.Context, req *http.Request, ret interface{}) err } if err := json.Unmarshal(body, ret); err != nil { // We received a success response from the ES API but the body was in an unexpected format. - return fmt.Errorf("%s; %d: %s", err, resp.StatusCode, body) + return fmt.Errorf("unexpected format from elasticsearch api: %s; %d", err, resp.StatusCode) } // Body has been successfully read out. return nil @@ -250,5 +250,5 @@ func (c *Client) do(ctx context.Context, req *http.Request, ret interface{}) err } // We received some sort of API error. Let's return it. - return fmt.Errorf("%d: %s", resp.StatusCode, body) + return fmt.Errorf("error returned from elasticsearch api: %d", resp.StatusCode) }