private void handleError(Response<Object> response, HttpRequest httpRequest) { final Object obj = response.body(); if (obj instanceof ServiceMethodNotFoundException) { writeResponse(httpRequest.getReceiver(), HttpStatus.NOT_FOUND, "application/json", jsonMapper.toJson(response.body()), response.headers()); } else if (obj instanceof HttpStatusCodeException) { final HttpStatusCodeException httpStatusCodeException = ((HttpStatusCodeException) obj); writeResponse(httpRequest.getReceiver(), httpStatusCodeException.code(), "application/json", jsonMapper.toJson(httpStatusCodeException.getMessage()), response.headers()); } else if (obj instanceof Throwable) { writeResponse(httpRequest.getReceiver(), HttpStatus.ERROR, "application/json", asJson(((Throwable) obj)), response.headers()); } else { writeResponse(httpRequest.getReceiver(), HttpStatus.ERROR, "application/json", jsonMapper.toJson(response.body()), response.headers()); } }
private void handleError(Response<Object> response, HttpRequest httpRequest) { final Object obj = response.body(); if (obj instanceof ServiceMethodNotFoundException) { writeResponse(httpRequest.getReceiver(), HttpStatus.NOT_FOUND, "application/json", jsonMapper.toJson(response.body()), response.headers()); } else if (obj instanceof HttpStatusCodeException) { final HttpStatusCodeException httpStatusCodeException = ((HttpStatusCodeException) obj); writeResponse(httpRequest.getReceiver(), httpStatusCodeException.code(), "application/json", jsonMapper.toJson(httpStatusCodeException.getMessage()), response.headers()); } else if (obj instanceof Throwable) { writeResponse(httpRequest.getReceiver(), HttpStatus.ERROR, "application/json", asJson(((Throwable) obj)), response.headers()); } else { writeResponse(httpRequest.getReceiver(), HttpStatus.ERROR, "application/json", jsonMapper.toJson(response.body()), response.headers()); } }
private void handleError(Response<Object> response, HttpRequest httpRequest) { final Object obj = response.body(); if (obj instanceof ServiceMethodNotFoundException) { writeResponse(httpRequest.getReceiver(), HttpStatus.NOT_FOUND, "application/json", jsonMapper.toJson(response.body()), response.headers()); } else if (obj instanceof HttpStatusCodeException) { final HttpStatusCodeException httpStatusCodeException = ((HttpStatusCodeException) obj); writeResponse(httpRequest.getReceiver(), httpStatusCodeException.code(), "application/json", jsonMapper.toJson(httpStatusCodeException.getMessage()), response.headers()); } else if (obj instanceof Throwable){ writeResponse(httpRequest.getReceiver(), HttpStatus.ERROR, "application/json", asJson(((Throwable) obj)), response.headers()); } else { writeResponse(httpRequest.getReceiver(), HttpStatus.ERROR, "application/json", jsonMapper.toJson(response.body()), response.headers()); } }