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