@Ignore @ExceptionHandler(value = HttpMessageNotReadableException.class) public @ResponseBody ResponseEntity<String> catchHttpMessageNotReadableException( HttpMessageNotReadableException exception) { LOGGER.error("REST Wrong Input Body Exception: " + exception.getMessage(), exception); return JsonRestUtils.toJsonResponse( HttpStatus.BAD_REQUEST, new ErrorResponse(BUSINESS_ERROR_CODE, exception.getMessage())); }
@Override protected ResponseEntity<Object> handleHttpMessageNotReadable( final HttpMessageNotReadableException ex, final HttpHeaders headers, final HttpStatus status, final WebRequest request) { if (ex.getCause() instanceof Exception) { return handleExceptionInternal((Exception) ex.getCause(), null, headers, status, request); } else { return handleExceptionInternal(ex, null, headers, status, request); } }
/** Thrown by HttpMessageConverter implementations when the read method fails.. */ @ExceptionHandler(HttpMessageNotReadableException.class) public ResponseEntity<Map<String, Object>> handleHttpMessageNotReadableException( HttpMessageNotReadableException error) { Map<String, Object> errorMap = new HashMap<String, Object>(); errorMap.put("hasErrors", "true"); errorMap.put( "developerMessage", "Error parsing Json request to corresponding object." + " please form the correct JSON String "); errorMap.put("userMessage", ""); errorMap.put("moreInfo", error.getMessage()); errorMap.put("errorCode", HttpStatus.BAD_REQUEST); error.printStackTrace(); return new ResponseEntity<Map<String, Object>>(errorMap, HttpStatus.BAD_GATEWAY); }