private static ResponseEntity<?> notFound(HttpHeaders headers) { return response(HttpStatus.NOT_FOUND, headers, null); }
private static <T> ResponseEntity<T> response(HttpStatus status, HttpHeaders headers) { return response(status, headers, null); }
private static ResponseEntity<ExceptionMessage> errorResponse(HttpStatus status, HttpHeaders headers, Exception exception) { if (exception != null) { String message = exception.getMessage(); LOG.error(message, exception); if (StringUtils.hasText(message)) { return response(status, headers, new ExceptionMessage(exception)); } } return response(status, headers, null); }
/** * Handles {@link RepositoryConstraintViolationException}s by returning {@code 400 Bad Request}. * * @param o_O the exception to handle. * @return */ @ExceptionHandler ResponseEntity<RepositoryConstraintViolationExceptionMessage> handleRepositoryConstraintViolationException( RepositoryConstraintViolationException o_O) { return response(HttpStatus.BAD_REQUEST, new HttpHeaders(), new RepositoryConstraintViolationExceptionMessage(o_O, messageSourceAccessor)); }
/** * Send {@code 405 Method Not Allowed} and include the supported {@link org.springframework.http.HttpMethod}s in the * {@code Allow} header. * * @param o_O the exception to handle. * @return */ @ExceptionHandler ResponseEntity<Void> handle(HttpRequestMethodNotSupportedException o_O) { HttpHeaders headers = new HttpHeaders(); headers.setAllow(o_O.getSupportedHttpMethods()); return response(HttpStatus.METHOD_NOT_ALLOWED, headers); }
/** * Handles {@link ETagDoesntMatchException} by returning {@code 412 Precondition Failed}. * * @param o_O the exception to handle. * @return */ @ExceptionHandler ResponseEntity<Void> handle(ETagDoesntMatchException o_O) { HttpHeaders headers = o_O.getExpectedETag().addTo(new HttpHeaders()); return response(HttpStatus.PRECONDITION_FAILED, headers); }
private static ResponseEntity<?> notFound(HttpHeaders headers) { return response(HttpStatus.NOT_FOUND, headers, null); }
private static <T> ResponseEntity<T> response(HttpStatus status, HttpHeaders headers) { return response(status, headers, null); }
private static ResponseEntity<ExceptionMessage> errorResponse(HttpStatus status, HttpHeaders headers, Exception exception) { if (exception != null) { String message = exception.getMessage(); LOG.error(message, exception); if (StringUtils.hasText(message)) { return response(status, headers, new ExceptionMessage(exception)); } } return response(status, headers, null); }
/** * Handles {@link RepositoryConstraintViolationException}s by returning {@code 400 Bad Request}. * * @param o_O the exception to handle. * @return */ @ExceptionHandler ResponseEntity<RepositoryConstraintViolationExceptionMessage> handleRepositoryConstraintViolationException( RepositoryConstraintViolationException o_O) { return response(HttpStatus.BAD_REQUEST, new HttpHeaders(), new RepositoryConstraintViolationExceptionMessage(o_O, messageSourceAccessor)); }
/** * Handles {@link ETagDoesntMatchException} by returning {@code 412 Precondition Failed}. * * @param o_O the exception to handle. * @return */ @ExceptionHandler ResponseEntity<Void> handle(ETagDoesntMatchException o_O) { HttpHeaders headers = o_O.getExpectedETag().addTo(new HttpHeaders()); return response(HttpStatus.PRECONDITION_FAILED, headers); }
/** * Send {@code 405 Method Not Allowed} and include the supported {@link org.springframework.http.HttpMethod}s in the * {@code Allow} header. * * @param o_O the exception to handle. * @return */ @ExceptionHandler ResponseEntity<Void> handle(HttpRequestMethodNotSupportedException o_O) { HttpHeaders headers = new HttpHeaders(); headers.setAllow(o_O.getSupportedHttpMethods()); return response(HttpStatus.METHOD_NOT_ALLOWED, headers); }