private ClientHttpResponse forward(RibbonCommandContext context) throws Exception { Map<String, Object> info = this.helper.debug( context.getVerb(), context.getUri(), context.getHeaders(), context.getParams(), context.getRequestEntity()); RibbonCommand command = ribbonCommandFactory.create(context); try { ClientHttpResponse response = command.execute(); this.helper.appendDebug(info, response.getStatusCode().value(), response.getHeaders()); return response; } catch (HystrixRuntimeException ex) { info.put("status", "500"); if (ex.getFallbackException() != null && ex.getFallbackException().getCause() != null && ex.getFallbackException().getCause() instanceof ClientException) { ClientException cause = (ClientException) ex.getFallbackException().getCause(); throw new ZuulException(cause, "Forwarding error", 500, cause.getErrorType().toString()); } throw new ZuulException(ex, "Forwarding error", 500, ex.getFailureType().toString()); } }
protected T execute() throws Throwable { HystrixCommand<HystrixResult<T>> command = createHystrixCommand(); HystrixResult<T> result; try { result = command.execute(); } catch (HystrixRuntimeException e) { // TODO: Add unit test for this case e.printStackTrace(); throw new ServiceUnavailableException(e.getFailureType().toString()); } throwExceptionIfExecutionFailed(result); return result.getResult(); }