Class NullPaymentException
java.lang.Object
java.lang.Throwable
java.lang.Exception
com.goldenleaf.shop.exception.NullPaymentException
- All Implemented Interfaces:
Serializable
Checked exception thrown when an operation requires a valid, non-null payment method
(typically a
CreditCard or other payment entity),
but null is supplied or the payment reference is missing.
Payment information is mandatory for critical operations such as order checkout,
payment processing, or associating a saved card with a customer. Allowing null
payments would result in incomplete orders, failed transactions, or orphaned data.
Typical scenarios that trigger this exception:
- Attempting to place an order without selecting a payment method
- Calling constructors or service methods that expect a payment object with
null - Creating a
Customerwith anullpayments list when the business rules forbid it - Checkout flow where the selected
CreditCardcould not be loaded (e.g., removed concurrently) - Batch processing, admin tools, or data migration trying to process transactions without an associated payment method
This is a checked exception, forcing the caller to explicitly handle the missing payment case. It represents a recoverable validation/state error that commonly occurs during checkout and order finalization.
- Since:
- 1.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionNullPaymentException(String message) Constructs a new null-payment exception with the specified detail message.NullPaymentException(String message, Throwable cause) Constructs a new null-payment 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
-
NullPaymentException
Constructs a new null-payment exception with the specified detail message.- Parameters:
message- the detail message (e.g. "Payment method cannot be null") Saved for later retrieval byThrowable.getMessage()
-
NullPaymentException
Constructs a new null-payment exception with the specified detail message and cause.Useful when wrapping lower-level errors (e.g., entity not found, lazy-initialization exception, payment gateway failure, etc.).
- Parameters:
message- the detail messagecause- the root cause of this exception- Since:
- 1.2
-