Skip to content

Commit a096edc

Browse files
Merge #765
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]>
2 parents f574002 + 02276d7 commit a096edc

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/main/java/com/meilisearch/sdk/HttpClient.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,14 @@ <S, T> T put(String api, S body, Class<T> targetClass) throws MeilisearchExcepti
133133
*/
134134
<S, T> T patch(String api, S body, Class<T> targetClass) throws MeilisearchException {
135135
HttpRequest requestConfig = request.create(HttpMethod.PATCH, api, this.headers, body);
136-
HttpResponse<T> httpRequest = this.client.patch(requestConfig);
137-
HttpResponse<T> httpResponse = response.create(httpRequest, targetClass);
136+
HttpResponse<T> httpResponse = this.client.patch(requestConfig);
138137

139138
if (httpResponse.getStatusCode() >= 400) {
140139
throw new MeilisearchApiException(
141140
jsonHandler.decode(httpResponse.getContent(), APIError.class));
142141
}
143-
return httpResponse.getContent();
142+
143+
return response.create(httpResponse, targetClass).getContent();
144144
}
145145

146146
/**

0 commit comments

Comments
 (0)