/** * 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({ Exception.class }) return new VndErrors("error", clientMesagesString);
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); } }
@ResponseBody @ExceptionHandler(UserNotFoundException.class) @ResponseStatus(HttpStatus.NOT_FOUND) VndErrors userNotFoundExceptionHandler(UserNotFoundException ex) { return new VndErrors("error", ex.getMessage()); } }
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); }
@ResponseBody @ExceptionHandler(UserNotFoundException.class) @ResponseStatus(HttpStatus.NOT_FOUND) VndErrors userNotFoundExceptionHandler(UserNotFoundException ex) { return new VndErrors("error", ex.getMessage()); } }
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); } }
/** * * 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()); }
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); } }
/** * Handles the general error case. Report server-side error. * * @param e the exception to be handled * * @return VndErrors see {@link VndErrors} */ @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); }
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. Log track trace at error level * * @param e the exception not handled by other exception handler methods * @return the error response in JSON format with media type * application/vnd.error+json */ @ExceptionHandler(Exception.class) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) @ResponseBody public VndErrors onException(Exception e) { logger.error("Caught exception while handling a request", e); String logref = e.getClass().getSimpleName(); String msg = getExceptionMessage(e); return new VndErrors(logref, msg); }
@Override public void handleError(ClientHttpResponse response) throws IOException { VndErrors vndErrors = null; try { if (HttpStatus.FORBIDDEN.equals(response.getStatusCode())) { vndErrors = new VndErrors(vndErrorExtractor.extractData(response)); } else { vndErrors = vndErrorsExtractor.extractData(response); } } catch (Exception e) { super.handleError(response); } throw new DataFlowClientException(vndErrors); } }
/** * Handles the general error case. Log track trace at error level * * @param e the exception not handled by other exception handler methods * @return the error response in JSON format with media type * application/vnd.error+json */ @ExceptionHandler(Exception.class) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) @ResponseBody public VndErrors onException(Exception e) { logger.error("Caught exception while handling a request", e); String logref = e.getClass().getSimpleName(); String msg = getExceptionMessage(e); return new VndErrors(logref, msg); }
@Override public void handleError(ClientHttpResponse response) throws IOException { VndErrors vndErrors = null; try { if (HttpStatus.FORBIDDEN.equals(response.getStatusCode())) { vndErrors = new VndErrors(vndErrorExtractor.extractData(response)); } else { vndErrors = vndErrorsExtractor.extractData(response); } } catch (Exception e) { super.handleError(response); } throw new DataFlowClientException(vndErrors); } }
@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()); }