Class EmptyProductException
java.lang.Object
java.lang.Throwable
java.lang.Exception
com.goldenleaf.shop.exception.EmptyProductException
- All Implemented Interfaces:
Serializable
Checked exception thrown when an attempt is made to perform an operation that requires
a valid
Product instance, but the provided product
is null.
This exception is typically used in review-related logic where a review must be
unambiguously linked to an existing, persisted product. Allowing null products
would break referential integrity and lead to orphaned or meaningless reviews.
Common scenarios that trigger this exception:
- Calling
Customer.makeReview(com.goldenleaf.shop.model.Product, java.lang.String, int)withnullproduct - Creating a
Reviewentity with anullproduct reference - Adding a review via service/admin tools without selecting a product
- Validation failure during batch import of reviews where the product is missing
This is a checked exception, forcing the caller to explicitly handle the missing product case. It represents an expected, recoverable validation error rather than a programming defect.
- Since:
- 1.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionEmptyProductException(String message) Constructs a new empty-product exception with the specified detail message.EmptyProductException(String message, Throwable cause) Constructs a new empty-product exception with the specified detail message and cause. -
Method Summary
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
EmptyProductException
Constructs a new empty-product exception with the specified detail message.- Parameters:
message- the detail message (e.g. "Product cannot be null when creating a review") Saved for later retrieval byThrowable.getMessage()
-
EmptyProductException
Constructs a new empty-product exception with the specified detail message and cause.Useful when wrapping a lower-level exception (e.g., entity not found, persistence error, or validation framework issue).
- Parameters:
message- the detail messagecause- the root cause of this exception- Since:
- 1.2
-