Skip to content

Commit

Permalink
Update error message for invalid api response (#52) (#54)
Browse files Browse the repository at this point in the history
* update error messages for invalid api responses

Co-authored-by: Austin Gebauer <34121980+austingebauer@users.noreply.github.com>
  • Loading branch information
mickael-hc and austingebauer authored Mar 13, 2023
1 parent b9ca0dd commit a7f6ca1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}

0 comments on commit a7f6ca1

Please sign in to comment.