systemprompt_traits/
repository.rs1#[derive(Debug, thiserror::Error)]
2#[non_exhaustive]
3pub enum RepositoryError {
4 #[error("database error: {0}")]
5 Database(Box<dyn std::error::Error + Send + Sync>),
6
7 #[error("entity not found: {0}")]
8 NotFound(String),
9
10 #[error("serialization error: {0}")]
11 Serialization(#[from] serde_json::Error),
12
13 #[error("invalid data: {0}")]
14 InvalidData(String),
15
16 #[error("constraint violation: {0}")]
17 ConstraintViolation(String),
18
19 #[error("{0}")]
20 Other(#[from] anyhow::Error),
21}
22
23impl RepositoryError {
24 pub fn database(err: impl std::error::Error + Send + Sync + 'static) -> Self {
25 Self::Database(Box::new(err))
26 }
27}