private void handleHttpFailure(Exchange exchange) { HttpOperationFailedException e = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, HttpOperationFailedException.class); exchange.getOut().setHeaders(exchange.getIn().getHeaders()); exchange.getOut().setBody(String.format(RESPONSE_STRING_FORMAT, String.format("%d %s", e.getStatusCode(), e.getResponseBody()) )); }
if (locationHeader != null) { redirectLocation = locationHeader.getValue(); answer = new HttpOperationFailedException(uri, responseCode, statusText, redirectLocation, headers, copy); } else { answer = new HttpOperationFailedException(uri, responseCode, statusText, null, headers, copy); answer = new HttpOperationFailedException(uri, responseCode, statusText, null, headers, copy);
@Override public void process(Exchange exchange) throws Exception { final HttpOperationFailedException exception = exchange.getProperty( Exchange.EXCEPTION_CAUGHT, HttpOperationFailedException.class); if (null != exception && null != exception.getResponseHeaders().get( ExceptionMappingConstants.EXCEPTION_BODY_HEADER)) { final String body = exception.getResponseHeaders().get( ExceptionMappingConstants.EXCEPTION_BODY_HEADER); LOG.info("Catched error in route: " + body); final SAXBuilder sxb = new SAXBuilder(); final Document doc = sxb.build(new StringReader(body)); exchange.getIn().setBody( doc.getRootElement() .getChild(ExceptionMappingConstants.EXCEPTION_MESSAGE).getText()); } }
final Exception cause = new HttpOperationFailedException(uri, code, statusText, null, headers, bodyText);
private void handleHttpFailure(Exchange exchange) { HttpOperationFailedException e = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, HttpOperationFailedException.class); exchange.getOut().setHeaders(exchange.getIn().getHeaders()); exchange.getOut().setBody(String.format(RESPONSE_STRING_FORMAT, String.format("%d %s", e.getStatusCode(), e.getResponseBody()) )); } }