Advertisement
Guest User

Untitled

a guest
Jul 25th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. @ExceptionHandler(HttpMessageNotReadableException.class)
  2. @ResponseStatus(value = HttpStatus.BAD_REQUEST)
  3. @ResponseBody
  4. protected ErrorMessage handleJsonException(final HttpMessageNotReadableException ex, final HttpServletRequest request)
  5. {
  6. if (ex.getCause() instanceof JsonParseException)
  7. {
  8. // some code
  9. }
  10. if (ex .getCause() instanceof JsonMappingException)
  11. {
  12. // some code
  13. }
  14. }
  15.  
  16. {firstName":"abc","lastName":"xyz"}
  17.  
  18. Throwable throwable = ex.getCause();
  19. String field = invalidFormatException.getTargetType().getTypeName();
  20. String message = invalidFormatException.getOriginalMessage();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement