@Override public void onNext(PreResponse preResponse) { publishResponse(httpResponseMaker.buildResponse(preResponse, apiRequest, containerRequestContext)); }
/** * Method to handle an error case from its observables. Default argument for this method is Throwable. * Customized this argument as Exception which contains the attributes to prepare the error Response. * If the throwable is not the type of `ResponseException`, then it will be re-thrown as RuntimeException. * * @param responseException An object contains error response attributes wrapped along with an Exception object */ @Override public void onError(Throwable responseException) { if (responseException instanceof ResponseException) { ResponseException resException = (ResponseException) responseException; publishResponse( httpResponseMaker.buildErrorResponse( resException.getStatusCode(), resException.getReason(), resException.getDescription(), resException.getDruidQuery() ) ); } else { LOG.error("Failed to publish error Response", responseException); throw new RuntimeException("Failed to publish error Response", responseException); } }