Class IncorrectPriceException

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

public class IncorrectPriceException extends Exception
Checked exception thrown when an attempt is made to set or update a product price (or any monetary amount) with an invalid or unacceptable value.

According to the current business rules, a price must satisfy the following constraints:

  • Must be greater than or equal to zero (negative prices are not allowed)
  • Cannot be null when persisting a Product
  • Typically represented as BigDecimal to avoid floating-point precision issues
  • May have additional restrictions (e.g., maximum value, specific scale/precision)

Typical scenarios that trigger this exception:

  • Admin or seller enters a negative price while creating/updating a product
  • Calling Product#setPrice(BigDecimal) with null or a negative value
  • Data import or integration process submitting invalid pricing information
  • Dynamic pricing engine generating an out-of-range or malformed price
  • Discount/promotion logic accidentally resulting in a negative final price

This is a checked exception, forcing the caller to explicitly handle invalid pricing situations. It represents a recoverable business-rule violation that commonly occurs during product management and order processing.

Since:
1.0
See Also:
  • Constructor Details

    • IncorrectPriceException

      public IncorrectPriceException(String message)
      Constructs a new incorrect-price exception with the specified detail message.
      Parameters:
      message - the detail message (e.g. "Price cannot be negative or null") Saved for later retrieval by Throwable.getMessage()
    • IncorrectPriceException

      public IncorrectPriceException(String message, Throwable cause)
      Constructs a new incorrect-price exception with the specified detail message and cause.

      Useful when wrapping lower-level errors (e.g., arithmetic exceptions, validation framework failures, or constraint violations).

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