Skip to content

Commit 02276d7

Browse files
committed
Fix #764 throw MeilisearchApiException on response codes >= 400 when using patch method in httpclient
1 parent 9d8616d commit 02276d7

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)