Class IncorrectPriceException
java.lang.Object
java.lang.Throwable
java.lang.Exception
com.goldenleaf.shop.exception.IncorrectPriceException
- All Implemented Interfaces:
Serializable
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
nullwhen persisting aProduct - Typically represented as
BigDecimalto 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)withnullor 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 Summary
ConstructorsConstructorDescriptionIncorrectPriceException(String message) Constructs a new incorrect-price exception with the specified detail message.IncorrectPriceException(String message, Throwable cause) Constructs a new incorrect-price exception with the specified detail message and cause. -
Method Summary
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
IncorrectPriceException
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 byThrowable.getMessage()
-
IncorrectPriceException
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 messagecause- the root cause of this exception- Since:
- 1.2
-