Class EmptyShoppingCartException
java.lang.Object
java.lang.Throwable
java.lang.Exception
com.goldenleaf.shop.exception.EmptyShoppingCartException
- All Implemented Interfaces:
Serializable
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
Customerwithnullshopping 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 Summary
ConstructorsConstructorDescriptionEmptyShoppingCartException(String message) Constructs a new empty-shopping-cart exception with the specified detail message.EmptyShoppingCartException(String message, Throwable cause) Constructs a new empty-shopping-cart 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
-
EmptyShoppingCartException
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 byThrowable.getMessage()
-
EmptyShoppingCartException
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 messagecause- the root cause of this exception- Since:
- 1.2
-