2026-04-07 02:50:19 +08:00
|
|
|
#[derive(Debug, thiserror::Error)]
|
|
|
|
|
pub enum DataLayerError {
|
|
|
|
|
#[error("invalid configuration: {0}")]
|
|
|
|
|
InvalidConfiguration(String),
|
|
|
|
|
|
|
|
|
|
#[error("invalid input: {0}")]
|
|
|
|
|
InvalidInput(String),
|
|
|
|
|
|
|
|
|
|
#[error("postgres error: {0}")]
|
|
|
|
|
Postgres(String),
|
|
|
|
|
|
|
|
|
|
#[error("redis error: {0}")]
|
|
|
|
|
Redis(String),
|
|
|
|
|
|
2026-05-05 18:27:36 +08:00
|
|
|
#[error("sql error: {0}")]
|
|
|
|
|
Sql(String),
|
|
|
|
|
|
2026-04-07 02:50:19 +08:00
|
|
|
#[error("operation timed out: {0}")]
|
|
|
|
|
TimedOut(String),
|
|
|
|
|
|
|
|
|
|
#[error("unexpected database value: {0}")]
|
|
|
|
|
UnexpectedValue(String),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl DataLayerError {
|
|
|
|
|
pub fn postgres(error: impl std::fmt::Display) -> Self {
|
|
|
|
|
Self::Postgres(error.to_string())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn redis(error: impl std::fmt::Display) -> Self {
|
|
|
|
|
Self::Redis(error.to_string())
|
|
|
|
|
}
|
2026-05-05 18:27:36 +08:00
|
|
|
|
|
|
|
|
pub fn sql(error: impl std::fmt::Display) -> Self {
|
|
|
|
|
Self::Sql(error.to_string())
|
|
|
|
|
}
|
2026-04-07 02:50:19 +08:00
|
|
|
}
|