disintegrate_postgres/error.rs
1use std::error::Error as StdError;
2use thiserror::Error;
3
4use crate::migrator;
5
6/// Represents all the ways a method can fail within Disintegrate Postgres.
7#[derive(Error, Debug)]
8pub enum Error {
9 /// Error returned from the migrator.
10 #[error(transparent)]
11 Migration(#[from] migrator::Error),
12 /// Error returned from the database.
13 #[error(transparent)]
14 Database(#[from] sqlx::Error),
15 /// An error occurred while deserializing an event payload.
16 #[error(transparent)]
17 Deserialization(#[from] disintegrate_serde::Error),
18 /// An error occurred while acquiring an append permit.
19 #[error(transparent)]
20 AppendPermit(#[from] tokio::sync::AcquireError),
21 /// An error occurred while mapping the event store event to the query event
22 #[error("unable to map the event store event to the query event: {0}")]
23 QueryEventMapping(#[source] Box<dyn StdError + 'static + Send + Sync>),
24 // An error occurred while attempting to persist events using an outdated version of the event set.
25 ///
26 /// This error indicates that another process has inserted a new event that was not included in the event stream query
27 /// used to make the current business decision. The event store's state has changed, potentially affecting the decision-making process.
28 #[error("concurrent modification error")]
29 Concurrency,
30}