Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1. Nu har jag typ provat med
  2. @RestControllerAdvice
  3. public class ExceptionHandler extends ResponseEntityExceptionHandler {
  4.     @Override
  5.     protected ResponseEntity<Object> handleExceptionInternal(java.lang.Exception e, Object body, HttpHeaders headers, HttpStatus status, WebRequest request) {
  6.         if (e instanceof HttpMessageNotReadableException && e.getCause() instanceof JsonParseException) {
  7.             return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY).build();
  8.         }
  9.         return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(handleAll(e));
  10.     }
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement