Package com.mt.ecommerce.product.config
Class ProductExceptionHandler
java.lang.Object
com.mt.ecommerce.product.config.ProductExceptionHandler
Global exception handler for product-related exceptions.
Catches specific exceptions and returns appropriate HTTP responses.
-
Constructor Details
-
ProductExceptionHandler
public ProductExceptionHandler()
-
-
Method Details
-
handleNotFoundException
@ExceptionHandler({ProductNotFoundException.class,CategoryNotFoundException.class,java.lang.IllegalArgumentException.class,NoOrderFound.class,ProductNotFoundException.class}) public org.springframework.http.ResponseEntity<Error> handleNotFoundException(RuntimeException ex) Handles not found exceptions and returns a 404 response.- Parameters:
ex
- the exception to handle- Returns:
- a ResponseEntity with error details and 404 status
-
error
@ExceptionHandler(java.lang.Exception.class) public org.springframework.http.ResponseEntity<Error> error(Exception ex) Handles all other exceptions and returns a 500 response.- Parameters:
ex
- the exception to handle- Returns:
- a ResponseEntity with error details and 500 status
-