private void checkResponse(Request request, Response response) { if (response.hasFailed()) { // check error first String msg = null; // try to parse the answer try { EsHadoopException ex = errorExtractor.extractError(this.<Map> parseContent(response.body(), null)); msg = (ex != null) ? ex.toString() : null; if (response.isClientError()) { msg = msg + "\n" + request.body(); } else { msg = errorExtractor.prettify(msg, request.body()); } } catch (Exception ex) { // can't parse message, move on } if (!StringUtils.hasText(msg)) { msg = String.format("[%s] on [%s] failed; server[%s] returned [%s|%s:%s]", request.method().name(), request.path(), response.uri(), response.status(), response.statusDescription(), IOUtils.asStringAlways(response.body())); } throw new EsHadoopInvalidRequest(msg); } }
private void checkResponse(Request request, Response response) { if (response.hasFailed()) { // check error first String msg = null; // try to parse the answer try { msg = extractError(this.<Map> parseContent(response.body(), null)); if (response.isClientError()) { msg = msg + "\n" + request.body(); } else { msg = prettify(msg, request.body()); } } catch (Exception ex) { // can't parse message, move on } if (!StringUtils.hasText(msg)) { msg = String.format("[%s] on [%s] failed; server[%s] returned [%s|%s:%s]", request.method().name(), request.path(), response.uri(), response.status(), response.statusDescription(), IOUtils.asStringAlways(response.body())); } throw new EsHadoopInvalidRequest(msg); } }
private void checkResponse(Request request, Response response) { if (response.hasFailed()) { // check error first String msg = null; // try to parse the answer try { EsHadoopException ex = errorExtractor.extractError(this.<Map> parseContent(response.body(), null)); msg = (ex != null) ? ex.toString() : null; if (response.isClientError()) { msg = msg + "\n" + request.body(); } else { msg = errorExtractor.prettify(msg, request.body()); } } catch (Exception ex) { // can't parse message, move on } if (!StringUtils.hasText(msg)) { msg = String.format("[%s] on [%s] failed; server[%s] returned [%s|%s:%s]", request.method().name(), request.path(), response.uri(), response.status(), response.statusDescription(), IOUtils.asStringAlways(response.body())); } throw new EsHadoopInvalidRequest(msg); } }
private void checkResponse(Request request, Response response) { if (response.hasFailed()) { // check error first String msg = null; // try to parse the answer try { EsHadoopException ex = errorExtractor.extractError(this.<Map> parseContent(response.body(), null)); msg = (ex != null) ? ex.toString() : null; if (response.isClientError()) { msg = msg + "\n" + request.body(); } else { msg = errorExtractor.prettify(msg, request.body()); } } catch (Exception ex) { // can't parse message, move on } if (!StringUtils.hasText(msg)) { msg = String.format("[%s] on [%s] failed; server[%s] returned [%s|%s:%s]", request.method().name(), request.path(), response.uri(), response.status(), response.statusDescription(), IOUtils.asStringAlways(response.body())); } throw new EsHadoopInvalidRequest(msg); } }
private void checkResponse(Request request, Response response) { if (response.hasFailed()) { // check error first String msg = null; // try to parse the answer try { EsHadoopException ex = errorExtractor.extractError(this.<Map> parseContent(response.body(), null)); msg = (ex != null) ? ex.toString() : null; if (response.isClientError()) { msg = msg + "\n" + request.body(); } else { msg = errorExtractor.prettify(msg, request.body()); } } catch (Exception ex) { // can't parse message, move on } if (!StringUtils.hasText(msg)) { msg = String.format("[%s] on [%s] failed; server[%s] returned [%s|%s:%s]", request.method().name(), request.path(), response.uri(), response.status(), response.statusDescription(), IOUtils.asStringAlways(response.body())); } throw new EsHadoopInvalidRequest(msg); } }