* is {@link org.springframework.http.HttpStatus.Series#CLIENT_ERROR}, a {@link HttpServerErrorException}
* if it is {@link org.springframework.http.HttpStatus.Series#SERVER_ERROR},
* and a {@link RestClientException} in other cases.
*/
public void handleError(ClientHttpResponse response) throws IOException {
HttpStatus statusCode = response.getStatusCode();
MediaType contentType = response.getHeaders().getContentType();
Charset charset = contentType != null ? contentType.getCharSet() : null;
byte[] body = getResponseBody(response);
switch (statusCode.series()) {
case CLIENT_ERROR:
throw new HttpClientErrorException(statusCode, response.getStatusText(), body, charset);
case SERVER_ERROR:
throw new HttpServerErrorException(statusCode, response.getStatusText(), body, charset);
default: