Class GlobalExceptionHandler

java.lang.Object
com.glowmart.shop_management.exception.GlobalExceptionHandler

@ControllerAdvice public class GlobalExceptionHandler extends Object
Global exception handler for handling custom exceptions across the application.
  • Constructor Details

    • GlobalExceptionHandler

      public GlobalExceptionHandler()
  • Method Details

    • handleDuplicateEmailException

      public org.springframework.http.ResponseEntity<String> handleDuplicateEmailException(DuplicateEmailException exception)
      Handles DuplicateEmailException and returns a response with a 409 Conflict status.
      Parameters:
      exception - the exception thrown when a duplicate email is encountered
      Returns:
      a ResponseEntity containing the exception message and HTTP status
    • handleNotFoundRoleException

      public org.springframework.http.ResponseEntity<String> handleNotFoundRoleException(NotFoundException exception)
      Handles NotFoundException and returns a response with a 404 Not Found status.
      Parameters:
      exception - the exception thrown when a requested role is not found
      Returns:
      a ResponseEntity containing the exception message and HTTP status
    • handleNotValidNameException

      public org.springframework.http.ResponseEntity<String> handleNotValidNameException(NotValidException exception)
      Handles NotValidException and returns a response with a 400 Bad Request status.

      This method is invoked when an invalid name is provided in a request, ensuring clients receive a clear error message along with the appropriate HTTP status code.

      Parameters:
      exception - the exception thrown when a provided name is not valid
      Returns:
      a ResponseEntity containing the exception message and HTTP status