23 lines
504 B
Rust
Raw Normal View History

2024-08-19 19:40:14 +02:00
use diesel::result::Error;
use thiserror::Error;
/// Error type for CRUD operations
#[derive(Debug, PartialEq, Error)]
2024-08-19 19:40:14 +02:00
pub enum CrudError {
#[error("Resource not found")]
NotFound,
#[error("Database pool error: {0}")]
PoolError(String),
#[error(transparent)]
Other(Error),
}
impl From<Error> for CrudError {
fn from(error: Error) -> Self {
match error {
Error::NotFound => CrudError::NotFound,
_ => CrudError::Other(error),
}
}
}