Skip to content

Commit fab8922

Browse files
authored
Merge branch 'main' into InvalidTokenException
2 parents 814731c + 76be93b commit fab8922

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

linktreeclone-backend/src/main/java/br/com/linktreeclone/exception/RestExceptionHandler.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,16 @@ public ResponseEntity<ErrorResponse> handleUnauthorizedException(UnauthorizedExc
5050

5151
return new ResponseEntity<>(errorResponse, HttpStatus.FORBIDDEN);
5252
}
53+
54+
@ExceptionHandler(InvalidTokenException.class)
55+
public ResponseEntity<ErrorResponse> handleInvalidTokenException(InvalidTokenException ex, WebRequest request) {
56+
ErrorResponse errorResponse = new ErrorResponse(
57+
LocalDateTime.now(),
58+
HttpStatus.FORBIDDEN.value(),
59+
"Forbidden",
60+
ex.getMessage(),
61+
request.getDescription(false).replace("uri=", "")
62+
);
63+
return new ResponseEntity<>(errorResponse, HttpStatus.FORBIDDEN);
64+
}
5365
}

0 commit comments

Comments
 (0)