Skip to content

Commit

Permalink
Merge #765
Browse files Browse the repository at this point in the history
765: Fix Update settings api failure throws ClassCastException r=curquiza a=jdvalenzuelah


# Pull Request

## Related issue
Fixes #764

## What does this PR do?
- throw MeilisearchApiException on response codes >= 400 when using patch method in httpclient

## PR checklist
Please check if your PR fulfills the following requirements:
- [x] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
- [x] Have you read the contributing guidelines?
- [x] Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!


Co-authored-by: Josue Valenzuela <[email protected]>
  • Loading branch information
meili-bors[bot] and jdvalenzuelah authored Oct 2, 2024
2 parents f574002 + 02276d7 commit a096edc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main/java/com/meilisearch/sdk/HttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,14 @@ <S, T> T put(String api, S body, Class<T> targetClass) throws MeilisearchExcepti
*/
<S, T> T patch(String api, S body, Class<T> targetClass) throws MeilisearchException {
HttpRequest requestConfig = request.create(HttpMethod.PATCH, api, this.headers, body);
HttpResponse<T> httpRequest = this.client.patch(requestConfig);
HttpResponse<T> httpResponse = response.create(httpRequest, targetClass);
HttpResponse<T> httpResponse = this.client.patch(requestConfig);

if (httpResponse.getStatusCode() >= 400) {
throw new MeilisearchApiException(
jsonHandler.decode(httpResponse.getContent(), APIError.class));
}
return httpResponse.getContent();

return response.create(httpResponse, targetClass).getContent();
}

/**
Expand Down

0 comments on commit a096edc

Please sign in to comment.