/** * Modifies the HTTP response and body based on the provided HaltException. * * @param httpResponse The HTTP servlet response * @param body The body content * @param halt The halt exception object */ public static void modify(HttpServletResponse httpResponse, Body body, HaltException halt) { httpResponse.setStatus(halt.statusCode()); if (halt.body() != null) { body.set(halt.body()); } else { body.set(""); } } }
/** * Modifies the HTTP response and body based on the provided HaltException. * * @param httpResponse The HTTP servlet response * @param body The body content * @param halt The halt exception object */ public static void modify(HttpServletResponse httpResponse, Body body, HaltException halt) { httpResponse.setStatus(halt.statusCode()); if (halt.body() != null) { body.set(halt.body()); } else { body.set(""); } } }
private boolean bodyHasErrorDetail(Throwable throwable, ErrorResponder.ErrorDetail errorDetail) { HaltException haltException = (HaltException) throwable; DocumentContext jsonPath = JsonPath.parse(haltException.body()); return errorDetail.equals(new ErrorResponder.ErrorDetail( jsonPath.read("$.statusCode"), jsonPath.read("$.type"), jsonPath.read("$.message"), Optional.ofNullable(jsonPath.read("$.details")))); }
private boolean bodyHasErrorDetail(Throwable throwable, ErrorResponder.ErrorDetail errorDetail) { HaltException haltException = (HaltException) throwable; DocumentContext jsonPath = JsonPath.parse(haltException.body()); return errorDetail.equals(new ErrorResponder.ErrorDetail( jsonPath.read("$.statusCode"), jsonPath.read("$.type"), jsonPath.read("$.message"), Optional.ofNullable(jsonPath.read("$.details")))); }