es_entity/
error.rs

1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum EsEntityError {
5    #[error("EsEntityError - UninitializedFieldError: {0}")]
6    UninitializedFieldError(#[from] derive_builder::UninitializedFieldError),
7    #[error("EsEntityError - Deserialization: {0}")]
8    EventDeserialization(#[from] serde_json::Error),
9    #[error("EntityError - NotFound")]
10    NotFound,
11    #[error("EntityError - ConcurrentModification")]
12    ConcurrentModification,
13}
14
15#[derive(Error, Debug)]
16#[error("CursorDestructureError: couldn't turn {0} into {1}")]
17pub struct CursorDestructureError(&'static str, &'static str);
18
19impl From<(&'static str, &'static str)> for CursorDestructureError {
20    fn from((name, variant): (&'static str, &'static str)) -> Self {
21        Self(name, variant)
22    }
23}
24
25#[derive(Error, Debug)]
26pub enum EsRepoError {
27    #[error("EsRepoError - Sqlx: {0}")]
28    Sqlx(#[from] sqlx::Error),
29    #[error("{0}")]
30    EsEntityError(EsEntityError),
31    #[error("{0}")]
32    CursorDestructureError(#[from] CursorDestructureError),
33}
34
35crate::from_es_entity_error!(EsRepoError);