pub enum AggregateError<T: Error> {
UserError(T),
AggregateConflict,
DatabaseConnectionError(Box<dyn Error + Send + Sync + 'static>),
DeserializationError(Box<dyn Error + Send + Sync + 'static>),
UnexpectedError(Box<dyn Error + Send + Sync + 'static>),
}Expand description
The base error for the framework.
Variants§
UserError(T)
This is the error returned when a user violates a business rule. The payload within
AggregateError::UserError should be used to pass information to inform the user of
the nature of problem.
The UserErrorPayload struct has been provided as a reference implementation for this
purpose.
§Handling
In a Restful application this should translate to a 400 response status.
AggregateConflict
A command has been rejected due to a conflict with another command on the same aggregate instance. This is handled by optimistic locking in systems backed by an RDBMS.
§Handling
In a Restful application this usually translates to a 503 or 429 response status, often with a Retry-After response header indicating that the user should try again.
DatabaseConnectionError(Box<dyn Error + Send + Sync + 'static>)
A error occurred while attempting to read or write from a database.
DeserializationError(Box<dyn Error + Send + Sync + 'static>)
A deserialization error occurred due to invalid JSON.
UnexpectedError(Box<dyn Error + Send + Sync + 'static>)
A technical error was encountered that prevented the command from being applied to the aggregate. In general the accompanying message should be logged for investigation rather than returned to the user.
Trait Implementations§
Source§impl<T> Display for AggregateError<T>
impl<T> Display for AggregateError<T>
Source§impl<T: Error> Error for AggregateError<T>
impl<T: Error> Error for AggregateError<T>
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()