use thiserror::Error;
#[derive(Error, Debug)]
pub enum DbError {
#[error("Series not found: {0}")]
SeriesNotFound(String),
#[error("I/O Error: {0}")]
Io(#[from] std::io::Error),
#[error("Serialization Error: {0}")]
Serialization(String),
#[error("Lock acquisition failed: {0}")]
LockError(String),
#[error("Invalid time range: start={start}, end={end}")]
InvalidTimeRange { start: u64, end: u64 },
#[error("Feature not implemented: {0}")]
NotImplemented(String),
#[error("Configuration Error: {0}")]
ConfigError(String),
#[error("Background task error: {0}")]
BackgroundTaskError(String),
#[error("Internal error: {0}")]
Internal(String),
}
impl<T> From<std::sync::PoisonError<T>> for DbError {
fn from(err: std::sync::PoisonError<T>) -> Self {
DbError::LockError(format!("Mutex/RwLock poisoned: {}", err))
}
}