Class EmptyExpiryException

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

public class EmptyExpiryException extends Exception
Checked exception thrown when an attempt is made to create or update a credit card without providing a valid expiry date (month/year).

The expiry date is a mandatory, non-null field for the CreditCard entity. This exception ensures that only cards with a properly defined expiration are accepted, preventing incomplete or invalid payment methods from being stored.

Typical scenarios that trigger this exception:

  • User submits a payment method form without selecting or entering an expiry date
  • Calling CreditCard.setExpiry(java.time.YearMonth) with null
  • Validation failure during checkout, registration of a new card, or data import
  • Business rule enforcement – cards must have a defined expiration date

This is a checked exception, requiring the caller to handle the situation explicitly. It represents an expected, recoverable validation error rather than a programming bug.

Since:
1.0
See Also:
  • Constructor Details

    • EmptyExpiryException

      public EmptyExpiryException(String message)
      Constructs a new empty-expiry exception with the specified detail message.
      Parameters:
      message - the detail message (e.g. "Credit card expiry date cannot be null") Saved for later retrieval by Throwable.getMessage()
    • EmptyExpiryException

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

      Useful when this validation exception wraps a lower-level technical exception (e.g., parsing error, constraint violation, or payment gateway issue).

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