@@ -157,18 +157,25 @@ public static BodyHandler<Void> discarding() {
157157 /**
158158 * Throws on HTTP error, or apply the provided body handler.
159159 * @param handler the body handler to apply on non-error HTTP responses
160+ * @param isSuccess a callback determining error cases
160161 * @return the body handler
161162 * @param <T> the type of the body handler
162163 */
163164 public static <T > Response .BodyHandler <T > throwOnError (
164- Response .BodyHandler <T > handler ,
165- Function <Response .ResponseInfo , Boolean > isSuccess
165+ final Response .BodyHandler <T > handler ,
166+ final Function <Response .ResponseInfo , Boolean > isSuccess
166167 ) {
167168 return responseinfo -> {
168169 if (isSuccess .apply (responseinfo )) {
169170 throw new ClientHttpException (
170- "An HTTP error has been returned from " +responseinfo .uri ()+" with status code " +responseinfo .statusCode (),
171- responseinfo .uri (), responseinfo .statusCode (), responseinfo .headers (), new String (responseinfo .body ().array (), StandardCharsets .UTF_8 )
171+ "An HTTP error has been returned from "
172+ + responseinfo .uri ()
173+ + " with status code "
174+ + responseinfo .statusCode (),
175+ responseinfo .uri (),
176+ responseinfo .statusCode (),
177+ responseinfo .headers (),
178+ new String (responseinfo .body ().array (), StandardCharsets .UTF_8 )
172179 );
173180 }
174181 return handler .apply (responseinfo );
0 commit comments