File tree Expand file tree Collapse file tree
rentplace/src/main/java/kattsyn/dev/rentplace/exceptions Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package kattsyn .dev .rentplace .exceptions ;
22
3+ import io .jsonwebtoken .ExpiredJwtException ;
34import jakarta .security .auth .message .AuthException ;
45import jakarta .servlet .http .HttpServletRequest ;
56import kattsyn .dev .rentplace .dtos .ErrorResponse ;
@@ -55,6 +56,17 @@ public ResponseEntity<ErrorResponse> handleValidationExceptions(AuthException ex
5556 return new ResponseEntity <>(response , HttpStatus .UNAUTHORIZED );
5657 }
5758
59+ @ ExceptionHandler (ExpiredJwtException .class )
60+ public ResponseEntity <ErrorResponse > handleValidationExceptions (ExpiredJwtException ex , WebRequest request ) {
61+ ErrorResponse response = new ErrorResponse (
62+ HttpStatus .UNAUTHORIZED .value (),
63+ "JSON WEB TOKEN EXPIRED" ,
64+ ex .getMessage (),
65+ request .getDescription (false ).replace ("uri=" , "" )
66+ );
67+ return new ResponseEntity <>(response , HttpStatus .UNAUTHORIZED );
68+ }
69+
5870 @ ExceptionHandler (Exception .class )
5971 public ResponseEntity <ErrorResponse > handleAllExceptions (Exception ex , WebRequest request ) {
6072 String path = "" ;
You can’t perform that action at this time.
0 commit comments