try {
if (isSuccess(request)) {
return request.body(HttpRequest.CHARSET_UTF8);
}
// TODO better handle error messages
throw new HttpException(request.url().toString(), request.code(), request.body());
} catch (HttpRequest.HttpRequestException e) {
throw new IllegalStateException("Fail to request " + request.url(), e.getCause());
}
}