Class EmptyAuthorException
java.lang.Object
java.lang.Throwable
java.lang.Exception
com.goldenleaf.shop.exception.EmptyAuthorException
- All Implemented Interfaces:
Serializable
Checked exception thrown when an attempt is made to create or process a review
without a valid author (customer).
This typically occurs in the Review entity
or in methods such as Customer.makeReview(com.goldenleaf.shop.model.Product, java.lang.String, int).
The author field must reference a persisted Customer
and must not be null.
Example scenarios that trigger this exception:
- Passing
nullas the customer when creating a review - Trying to save a review with an unassigned or detached author
- Business logic violation where anonymous reviews are not allowed
This is a checked exception, forcing the caller to handle or declare it — appropriate for validation errors that are recoverable and expected in normal application flow.
- Since:
- 1.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionEmptyAuthorException(String message) Constructs a new empty author exception with the specified detail message.EmptyAuthorException(String message, Throwable cause) Constructs a new empty author 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
-
EmptyAuthorException
Constructs a new empty author exception with the specified detail message.- Parameters:
message- the detail message explaining why the author is invalid (e.g., "Review author (customer) cannot be null") The message is saved for later retrieval byThrowable.getMessage().
-
EmptyAuthorException
Constructs a new empty author exception with the specified detail message and cause.Useful when this exception is a wrapper around a lower-level exception (e.g., persistence or validation failure).
- Parameters:
message- the detail messagecause- the cause of this exception (can be retrieved later byThrowable.getCause())- Since:
- 1.2
-