Class EmptyCardNumberException

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

public class EmptyCardNumberException extends Exception
Checked exception thrown when an attempt is made to create or update a credit card without providing a valid card number.

The card number is a mandatory, non-blank field for the CreditCard entity. This exception enforces data integrity and prevents incomplete or invalid payment method records from being persisted.

Common situations that trigger this exception:

  • Passing null, empty string, or whitespace-only value to CreditCard.setCardNumber(String)
  • User submitting a payment method form with missing card number
  • Validation failure during checkout or payment method registration
  • Importing or migrating payment data with incomplete records

This is a checked exception, requiring explicit handling or declaration. It represents a recoverable business/validation error rather than a programming defect.

Since:
1.0
See Also:
  • Constructor Details

    • EmptyCardNumberException

      public EmptyCardNumberException(String message)
      Constructs a new exception with the specified detail message.
      Parameters:
      message - the detail message explaining the validation failure (e.g., "Credit card number cannot be null or empty") The message is saved for later retrieval by Throwable.getMessage()
    • EmptyCardNumberException

      public EmptyCardNumberException(String message, Throwable cause)
      Constructs a new exception with the specified detail message and cause.

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

      Parameters:
      message - the detail message
      cause - the original cause of the error
      Since:
      1.2