event_sourcing/error/
create_error.rs

1use crate::error::AdapterError;
2use alloc::string::String;
3use snafu::Snafu;
4use uuid::Uuid;
5
6#[derive(Debug, Snafu)]
7#[snafu(visibility(pub(crate)))]
8pub enum CreateError {
9    #[snafu(display("Adapter error"))]
10    Adapter { source: AdapterError },
11
12    #[snafu(display("At least one event must be provided, the list of events was empty"))]
13    EmptyEventList,
14
15    #[snafu(display("Nil UUID can not be used as an aggregate id, perhaps you forgot to set it"))]
16    NilUuid,
17
18    #[snafu(display("The events had varying aggregate ids, this isn not allowed, all events must have the same aggregate id"))]
19    InconsistentAggregateId,
20
21    #[snafu(display(
22        "The events was in wrong order, the events must follow a consistent ordering such as 1,2,3"
23    ))]
24    InconsistentEventOrdering,
25
26    #[snafu(display("The aggregate with id '{id}' does already exist"))]
27    AggregateAlreadyExists { id: Uuid },
28
29    #[snafu(display(
30        "An aggregate with id '{external_id}' does already exist for the external id 'id'"
31    ))]
32    ExternalIdAlreadyExists { external_id: String, id: Uuid },
33}