Skip to main content

common/
error.rs

1// Generated by Qleany v1.7.0 from error.tera
2
3use thiserror::Error;
4
5use crate::types::EntityId;
6
7/// Errors that can occur in the repository / table layer.
8#[derive(Debug, Error)]
9pub enum RepositoryError {
10    /// An entity with the given id already exists.
11    #[error("{entity} id {id} already in use")]
12    DuplicateId { entity: &'static str, id: EntityId },
13
14    /// A relationship target does not exist.
15    #[error("{operation}: child entities do not exist: {ids:?}")]
16    MissingRelationshipTarget {
17        operation: &'static str,
18        ids: Vec<EntityId>,
19    },
20
21    /// Serialization / deserialization failed.
22    #[error("serialization error: {0}")]
23    Serialization(String),
24
25    /// A one-to-one constraint was violated.
26    #[error("constraint violation: {0}")]
27    ConstraintViolation(String),
28
29    /// A generic error (e.g. from anyhow).
30    #[error(transparent)]
31    Other(#[from] anyhow::Error),
32}