Class NullPaymentException

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

public class NullPaymentException extends Exception
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 Customer with a null payments list when the business rules forbid it
  • Checkout flow where the selected CreditCard could 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 Details

    • NullPaymentException

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

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