Class EmptyProductException

java.lang.Object
java.lang.Throwable
java.lang.Exception
com.goldenleaf.shop.exception.EmptyProductException
All Implemented Interfaces:
Serializable

public class EmptyProductException extends Exception
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:

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 Details

    • EmptyProductException

      public EmptyProductException(String message)
      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 by Throwable.getMessage()
    • EmptyProductException

      public EmptyProductException(String message, Throwable cause)
      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 message
      cause - the root cause of this exception
      Since:
      1.2