private <E extends Exception> ResponseEntity<VndErrors> error( final E exception, final HttpStatus httpStatus, final String logRef) { final String message = Optional.of(exception.getMessage()).orElse(exception.getClass().getSimpleName()); return new ResponseEntity<>(new VndErrors(logRef, message), httpStatus); }
private <E extends Exception> ResponseEntity<VndErrors> error(E e, HttpStatus httpStatus, String logref) { String msg = Optional.of(e.getMessage()).orElse(e.getClass().getSimpleName()); HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.setContentType(this.vndErrorMediaType); return new ResponseEntity<>(new VndErrors(logref, msg), httpHeaders, httpStatus); } }
private ResponseEntity<VndErrors> error( final Exception exception, final HttpStatus httpStatus, final String logRef) { final String message = Optional.of(exception.getMessage()).orElse(exception.getClass().getSimpleName()); return new ResponseEntity<>(new VndErrors(logRef, message), httpStatus); }
private <E extends Exception> ResponseEntity<VndErrors> error(E e, HttpStatus httpStatus, String logref) { String msg = Optional.of(e.getMessage()).orElse(e.getClass().getSimpleName()); HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.setContentType(this.vndErrorMediaType); return new ResponseEntity<>(new VndErrors(logref, msg), httpHeaders, httpStatus); } }
private <E extends Exception> ResponseEntity<VndErrors> error(E e, HttpStatus httpStatus, String logref) { String msg = Optional.of(e.getMessage()).orElse(e.getClass().getSimpleName()); HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.setContentType(this.vndErrorMediaType); return new ResponseEntity<>(new VndErrors(logref, msg), httpHeaders, httpStatus); } }
public static VndErrors vndErrors(final Map<String, String> errorAttributes) { final List<VndErrors.VndError> vndErrors = errorAttributes.entrySet().stream() .map(VndErrorFactory::vndError) .collect(toList()); return new VndErrors(vndErrors); }
/** * Handles the general error case. Report server-side error. */ @ExceptionHandler(Exception.class) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) @ResponseBody public VndErrors onException(Exception e) { String logref = logError(e); String msg = StringUtils.hasText(e.getMessage()) ? e.getMessage() : e.getClass().getSimpleName(); return new VndErrors(logref, msg); }
@ResponseBody @ExceptionHandler(UserNotFoundException.class) @ResponseStatus(HttpStatus.NOT_FOUND) VndErrors userNotFoundExceptionHandler(UserNotFoundException ex) { return new VndErrors("error", ex.getMessage()); } }
@ResponseBody @ExceptionHandler(UserNotFoundException.class) @ResponseStatus(HttpStatus.NOT_FOUND) VndErrors userNotFoundExceptionHandler(UserNotFoundException ex) { return new VndErrors("error", ex.getMessage()); } }
/** * * Catch <code>IllegalArgumentException</code> excption thrown by any endpoint and change the return code. * * @param ex * @return */ @ResponseBody @ExceptionHandler(IllegalArgumentException.class) @ResponseStatus(HttpStatus.BAD_REQUEST) VndErrors illegalArgumentExceptionHandler(IllegalArgumentException ex) { return new VndErrors(HttpStatus.BAD_REQUEST.getReasonPhrase(), ex.getMessage()); }
@ResponseBody @ExceptionHandler @ResponseStatus(HttpStatus.BAD_REQUEST) public VndErrors onJobExecutionAlreadyRunningException(JobExecutionAlreadyRunningException e) { String logref = logDebug(e); return new VndErrors(logref, e.getMessage()); }
@ResponseBody @ExceptionHandler @ResponseStatus(HttpStatus.BAD_REQUEST) public VndErrors onJobParametersInvalidException(JobParametersInvalidException e) { String logref = logDebug(e); return new VndErrors(logref, e.getMessage()); } }
@ResponseBody @ExceptionHandler @ResponseStatus(HttpStatus.NOT_FOUND) public VndErrors onNoSuchStepExecutionException(NoSuchStepExecutionException e) { String logref = logDebug(e); return new VndErrors(logref, e.getMessage()); }
@ResponseBody @ExceptionHandler @ResponseStatus(HttpStatus.BAD_REQUEST) public VndErrors onJobInstanceAlreadyCompleteException(JobInstanceAlreadyCompleteException e) { String logref = logDebug(e); return new VndErrors(logref, e.getMessage()); }
@ResponseBody @ExceptionHandler @ResponseStatus(HttpStatus.NOT_FOUND) public VndErrors onNoSuchJobException(NoSuchBatchJobException e) { String logref = logDebug(e); return new VndErrors(logref, e.getMessage()); }
@ResponseBody @ExceptionHandler @ResponseStatus(HttpStatus.NOT_FOUND) public VndErrors onNoSuchJobExecutionException(NoSuchJobExecutionException e) { String logref = logDebug(e); return new VndErrors(logref, e.getMessage()); }
@ResponseBody @ExceptionHandler @ResponseStatus(HttpStatus.NOT_FOUND) public VndErrors onJobExecutionNotRunningException(JobExecutionNotRunningException e) { String logref = logDebug(e); return new VndErrors(logref, e.getMessage()); }
@ResponseBody @ExceptionHandler @ResponseStatus(HttpStatus.BAD_REQUEST) public VndErrors onJobRestartException(JobRestartException e) { String logref = logDebug(e); return new VndErrors(logref, e.getMessage()); }
@ResponseBody @ExceptionHandler @ResponseStatus(HttpStatus.NOT_FOUND) public VndErrors onNoSuchJobInstanceException(NoSuchBatchJobInstanceException e) { String logref = logDebug(e); return new VndErrors(logref, e.getMessage()); }
/** * * Catch <code>EntityNotFoundException</code> excption thrown by any endpoint and change the return code. * * @param ex * @return */ @ResponseBody @ExceptionHandler(EntityNotFoundException.class) @ResponseStatus(HttpStatus.NOT_FOUND) VndErrors courseNotFoundExceptionHandler(EntityNotFoundException ex) { return new VndErrors(HttpStatus.NOT_FOUND.getReasonPhrase(), ex.getMessage()); }