Class GlobalExceptionHandler
java.lang.Object
com.glowmart.shop_management.exception.GlobalExceptionHandler
Global exception handler for handling custom exceptions across the application.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<String>HandlesDuplicateEmailExceptionand returns a response with a 409 Conflict status.org.springframework.http.ResponseEntity<String>handleNotFoundRoleException(NotFoundException exception) HandlesNotFoundExceptionand returns a response with a 404 Not Found status.org.springframework.http.ResponseEntity<String>handleNotValidNameException(NotValidException exception) HandlesNotValidExceptionand returns a response with a 400 Bad Request status.
-
Constructor Details
-
GlobalExceptionHandler
public GlobalExceptionHandler()
-
-
Method Details
-
handleDuplicateEmailException
public org.springframework.http.ResponseEntity<String> handleDuplicateEmailException(DuplicateEmailException exception) HandlesDuplicateEmailExceptionand returns a response with a 409 Conflict status.- Parameters:
exception- the exception thrown when a duplicate email is encountered- Returns:
- a
ResponseEntitycontaining the exception message and HTTP status
-
handleNotFoundRoleException
public org.springframework.http.ResponseEntity<String> handleNotFoundRoleException(NotFoundException exception) HandlesNotFoundExceptionand returns a response with a 404 Not Found status.- Parameters:
exception- the exception thrown when a requested role is not found- Returns:
- a
ResponseEntitycontaining the exception message and HTTP status
-
handleNotValidNameException
public org.springframework.http.ResponseEntity<String> handleNotValidNameException(NotValidException exception) HandlesNotValidExceptionand 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
ResponseEntitycontaining the exception message and HTTP status
-