es_entity/
error.rs

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