/** * Creates an ErrorCondition using the given throwable to provide an error condition value and * description. All throwables that are not service invocation exceptions will be mapped to {@link AmqpError#PRECONDITION_FAILED}. * * @param t The throwable to map to an error condition. * @return The ErrorCondition. */ static ErrorCondition getErrorCondition(final Throwable t) { if (ServiceInvocationException.class.isInstance(t)) { final ServiceInvocationException error = (ServiceInvocationException) t; switch (error.getErrorCode()) { case HttpURLConnection.HTTP_BAD_REQUEST: return ProtonHelper.condition(Constants.AMQP_BAD_REQUEST, error.getMessage()); case HttpURLConnection.HTTP_FORBIDDEN: return ProtonHelper.condition(AmqpError.UNAUTHORIZED_ACCESS, error.getMessage()); default: return ProtonHelper.condition(AmqpError.PRECONDITION_FAILED, error.getMessage()); } } else { return ProtonHelper.condition(AmqpError.PRECONDITION_FAILED, t.getMessage()); } } }
if (e.getCause() instanceof ServiceInvocationException) { final ServiceInvocationException sie = (ServiceInvocationException) e.getCause(); sampleResult.setResponseMessage(sie.getMessage()); sampleResult.setResponseCode(String.valueOf(sie.getErrorCode())); } else {
if (ctx.failure() instanceof ServiceInvocationException) { final ServiceInvocationException e = (ServiceInvocationException) ctx.failure(); sendError(ctx.response(), e.getErrorCode(), e.getMessage()); } else if (ctx.failure() instanceof HttpStatusException) { final HttpStatusException e = (HttpStatusException) ctx.failure();
if (ctx.failure() instanceof ServiceInvocationException) { final ServiceInvocationException e = (ServiceInvocationException) ctx.failure(); sendError(ctx.response(), e.getErrorCode(), e.getMessage()); } else if (ctx.failure() instanceof HttpStatusException) { final HttpStatusException e = (HttpStatusException) ctx.failure();