use thiserror::Error;
#[derive(Debug, Error)]
pub enum StorageError {
#[error("issue not found: {0}")]
NotFound(String),
#[error("issue already exists: {0}")]
AlreadyExists(String),
#[error("dependency would create a cycle from {from} to {to}")]
CycleDetected { from: String, to: String },
#[error("invalid dependency: {0}")]
InvalidDependency(String),
#[error("database error: {0}")]
Database(#[from] rusqlite::Error),
#[error("serialization error: {0}")]
Serialization(#[from] serde_json::Error),
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("transaction error: {0}")]
Transaction(String),
#[error("validation error: {0}")]
Validation(String),
#[error("storage is closed")]
Closed,
#[error("{0}")]
Other(String),
}
impl StorageError {
pub fn validation(msg: impl Into<String>) -> Self {
StorageError::Validation(msg.into())
}
pub fn other(msg: impl Into<String>) -> Self {
StorageError::Other(msg.into())
}
}