Package vaultWeb.exceptions
Class GlobalExceptionHandler
java.lang.Object
vaultWeb.exceptions.GlobalExceptionHandler
@ControllerAdvice(basePackages="vaultWeb.controllers")
public class GlobalExceptionHandler
extends Object
Global exception handler for all controllers in the "vaultWeb.controllers" package.
Catches specific exceptions and returns appropriate HTTP status codes and messages.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<String> Handles AccessDeniedException and returns 403 Forbidden.org.springframework.http.ResponseEntity<String> Handles AdminAccessDeniedException and returns 403 Forbidden.org.springframework.http.ResponseEntity<String> Handles AlreadyMemberException and returns 409 Conflict.org.springframework.http.ResponseEntity<String> Handles AlreadyVotedException and returns 400 Bad Request.org.springframework.http.ResponseEntity<String> handleBadCredentials(org.springframework.security.authentication.BadCredentialsException ex) Handles BadCredentialsException (invalid login) and returns 403 Forbidden.org.springframework.http.ResponseEntity<String> Handles DecryptionFailedException and returns 500 Internal Server Error.org.springframework.http.ResponseEntity<String> Handles DuplicateUsernameException and returns 409 Conflict.org.springframework.http.ResponseEntity<String> Handles EncryptionFailedException and returns 500 Internal Server Error.org.springframework.http.ResponseEntity<String> Handles GroupNotFoundException and returns 404 Not Found.org.springframework.http.ResponseEntity<String> Handles NotMemberException and returns 403 Forbidden.org.springframework.http.ResponseEntity<String> Handles PollDoesNotBelongToGroupException and returns 404 Not Found.org.springframework.http.ResponseEntity<String> Handles PollOptionNotFoundException and returns 404 Not Found.org.springframework.http.ResponseEntity<String> Handles any other RuntimeException and returns 500 Internal Server Error.org.springframework.http.ResponseEntity<String> Handles UnauthorizedException and returns 401 Unauthorized.org.springframework.http.ResponseEntity<String> Handles UserNotFoundException and returns 404 Not Found.
-
Constructor Details
-
GlobalExceptionHandler
public GlobalExceptionHandler()
-
-
Method Details
-
handleUserNotFound
@ExceptionHandler(UserNotFoundException.class) public org.springframework.http.ResponseEntity<String> handleUserNotFound(UserNotFoundException ex) Handles UserNotFoundException and returns 404 Not Found. -
handleGroupNotFound
@ExceptionHandler(GroupNotFoundException.class) public org.springframework.http.ResponseEntity<String> handleGroupNotFound(GroupNotFoundException ex) Handles GroupNotFoundException and returns 404 Not Found. -
handleUnauthorized
@ExceptionHandler(UnauthorizedException.class) public org.springframework.http.ResponseEntity<String> handleUnauthorized(UnauthorizedException ex) Handles UnauthorizedException and returns 401 Unauthorized. -
handleAccessDenied
@ExceptionHandler(java.nio.file.AccessDeniedException.class) public org.springframework.http.ResponseEntity<String> handleAccessDenied(AccessDeniedException ex) Handles AccessDeniedException and returns 403 Forbidden. -
handleAdminAccessDenied
@ExceptionHandler(AdminAccessDeniedException.class) public org.springframework.http.ResponseEntity<String> handleAdminAccessDenied(AdminAccessDeniedException ex) Handles AdminAccessDeniedException and returns 403 Forbidden. -
handleAlreadyMember
@ExceptionHandler(AlreadyMemberException.class) public org.springframework.http.ResponseEntity<String> handleAlreadyMember(AlreadyMemberException ex) Handles AlreadyMemberException and returns 409 Conflict. -
handleNotMember
@ExceptionHandler(NotMemberException.class) public org.springframework.http.ResponseEntity<String> handleNotMember(NotMemberException ex) Handles NotMemberException and returns 403 Forbidden. -
handleDuplicateUsername
@ExceptionHandler(DuplicateUsernameException.class) public org.springframework.http.ResponseEntity<String> handleDuplicateUsername(DuplicateUsernameException ex) Handles DuplicateUsernameException and returns 409 Conflict. -
handleBadCredentials
@ExceptionHandler(org.springframework.security.authentication.BadCredentialsException.class) public org.springframework.http.ResponseEntity<String> handleBadCredentials(org.springframework.security.authentication.BadCredentialsException ex) Handles BadCredentialsException (invalid login) and returns 403 Forbidden. -
handleAlreadyVoted
@ExceptionHandler(AlreadyVotedException.class) public org.springframework.http.ResponseEntity<String> handleAlreadyVoted(AlreadyVotedException ex) Handles AlreadyVotedException and returns 400 Bad Request. -
handleDecryptionFailed
@ExceptionHandler(DecryptionFailedException.class) public org.springframework.http.ResponseEntity<String> handleDecryptionFailed(DecryptionFailedException ex) Handles DecryptionFailedException and returns 500 Internal Server Error. -
handleEncryptionFailed
@ExceptionHandler(EncryptionFailedException.class) public org.springframework.http.ResponseEntity<String> handleEncryptionFailed(EncryptionFailedException ex) Handles EncryptionFailedException and returns 500 Internal Server Error. -
handlePollDoesNotBelongToGroup
@ExceptionHandler(PollDoesNotBelongToGroupException.class) public org.springframework.http.ResponseEntity<String> handlePollDoesNotBelongToGroup(PollDoesNotBelongToGroupException ex) Handles PollDoesNotBelongToGroupException and returns 404 Not Found. -
handlePollOptionNotFound
@ExceptionHandler(PollOptionNotFoundException.class) public org.springframework.http.ResponseEntity<String> handlePollOptionNotFound(PollOptionNotFoundException ex) Handles PollOptionNotFoundException and returns 404 Not Found. -
handleRuntimeException
@ExceptionHandler(java.lang.RuntimeException.class) public org.springframework.http.ResponseEntity<String> handleRuntimeException(RuntimeException ex) Handles any other RuntimeException and returns 500 Internal Server Error.
-