Class NullCustomerException

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

public class NullCustomerException extends Exception
Checked exception thrown when an operation requires a valid, non-null Customer instance, but null is provided or the customer reference is missing.

The Customer is a central entity in the shop domain. Many business operations (adding items to cart, creating reviews, managing payment methods, placing orders, applying bonus points, etc.) are performed in the context of an authenticated customer. Passing null instead of a proper customer would break referentialIntegrity and lead to inconsistent or orphaned data.

Typical scenarios that trigger this exception:

  • Calling CreditCard.setCustomer(Customer) with null
  • Attempting to add a payment method, review, or order item without an authenticated customer
  • Service-layer methods receiving a null customer from a controller or repository
  • Batch processing or data migration trying to associate entities with a non-existent customer
  • Security context issues where the current user could not be resolved

This is a checked exception, forcing the caller to explicitly handle the missing customer case. It represents a recoverable validation/state error that commonly occurs during user-bound operations.

Since:
1.0
See Also:
  • Constructor Details

    • NullCustomerException

      public NullCustomerException(String message)
      Constructs a new null-customer exception with the specified detail message.
      Parameters:
      message - the detail message (e.g. "Customer cannot be null") Saved for later retrieval by Throwable.getMessage()
    • NullCustomerException

      public NullCustomerException(String message, Throwable cause)
      Constructs a new null-customer exception with the specified detail message and cause.

      Useful when wrapping lower-level errors (e.g., Authentication being null, entity-not-found issues, lazy-initialization failures, etc.).

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