Class EmptyShoppingCartException

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

public class EmptyShoppingCartException extends Exception
Checked exception thrown when an attempt is made to perform an operation that requires a valid, non-null ShoppingCart instance, but the provided shopping cart is null.

The shopping cart is a mandatory one-to-one association for every Customer. Certain business operations (e.g. checkout, order creation, applying bonus points, calculating totals) cannot proceed without an active cart.

Typical scenarios that trigger this exception:

  • Creating a Customer with null shopping cart when the application policy requires an initialized cart
  • Calling service methods (checkout, apply discount, etc.) on a customer whose cart has not been created or was accidentally set to null
  • Administrative tools or data-migration processes trying to process a customer without an associated cart
  • Attempting to add items to or retrieve items from a non-existent cart

This is a checked exception, forcing the caller to handle the missing cart explicitly. It represents an expected, recoverable validation/state error rather than a programming bug.

Since:
1.0
See Also:
  • Constructor Details

    • EmptyShoppingCartException

      public EmptyShoppingCartException(String message)
      Constructs a new empty-shopping-cart exception with the specified detail message.
      Parameters:
      message - the detail message (e.g. "Shopping cart cannot be null") Saved for later retrieval by Throwable.getMessage()
    • EmptyShoppingCartException

      public EmptyShoppingCartException(String message, Throwable cause)
      Constructs a new empty-shopping-cart exception with the specified detail message and cause.

      Useful when wrapping a lower-level exception (e.g., lazy-initialization failure, entity-not-found error, or persistence issue).

      Parameters:
      message - the detail message
      cause - the root cause of this exception
      Since:
      1.2