nitinol_projection/
errors.rs

1use nitinol_resolver::errors::ResolveError;
2
3#[derive(Debug, thiserror::Error)]
4pub enum ProjectionError {
5    #[error("Failed to read protocol. {0}")]
6    Protocol(#[from] nitinol_protocol::errors::ProtocolError),
7
8    #[error(transparent)]
9    NotCompatible(#[from] NotCompatible),
10
11    #[error("First formation is not implemented.")]
12    FirstFormation,
13
14    #[error(transparent)]
15    DeserializeEvent(#[from] nitinol_core::errors::DeserializeError),
16
17    #[error("An error occurred while applying the event. {backtrace}")]
18    ApplyEvent { backtrace: String },
19}
20
21#[derive(Debug, thiserror::Error)]
22pub enum RejectProjection {
23    #[error("Projection interrupted. This is a user defined behavior.")]
24    Interrupted,
25}
26
27#[derive(Debug, thiserror::Error)]
28#[error("There are data incompatible with Mapping. key:{key}")]
29pub struct NotCompatible {
30    pub key: String,
31}
32
33impl From<ResolveError> for ProjectionError {
34    fn from(value: ResolveError) -> Self {
35        match value {
36            ResolveError::Deserialize(e) => Self::DeserializeEvent(e),
37            ResolveError::InProcess { trace } => Self::ApplyEvent { backtrace: trace },
38        }
39    }
40}