private static void handle4xxStatus(String body, int status, GenericUrl uri)
throws GeoIp2Exception, HttpException {
if (body == null) {
throw new HttpException("Received a " + status + " error for "
+ uri + " with no body", status, uri.toURL());
}
Map<String, String> content;
try {
ObjectMapper mapper = new ObjectMapper();
content = mapper.readValue(body,
new TypeReference<HashMap<String, String>>() {
});
handleErrorWithJsonBody(content, body, status, uri);
} catch (HttpException e) {
throw e;
} catch (IOException e) {
throw new HttpException("Received a " + status + " error for "
+ uri + " but it did not include the expected JSON body: "
+ body, status, uri.toURL());
}
}