Advertisement
Guest User

Untitled

a guest
Dec 13th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.51 KB | None | 0 0
  1. @ControllerAdvice
  2. final class AppExceptionHandler {
  3.  
  4.     @ExceptionHandler({NotFoundException.class})
  5.     ResponseEntity notFoundHandler(Exception e) {
  6.         return ResponseEntity
  7.                 .status(HttpStatus.NOT_FOUND)
  8.                 .body(e.getMessage());
  9.     }
  10.  
  11.     @ExceptionHandler({IOException.class})
  12.     ResponseEntity iOExceptionHandler(Exception e) {
  13.         return ResponseEntity
  14.                 .status(HttpStatus.INTERNAL_SERVER_ERROR)
  15.                 .body(e.getMessage());
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement