use thiserror::Error;
pub type Result<T> = std::result::Result<T, SnapshotError>;
#[derive(Error, Debug)]
pub enum SnapshotError {
#[error("Snapshot not found: {0}")]
SnapshotNotFound(String),
#[error("Corrupted snapshot: {0}")]
CorruptedSnapshot(String),
#[error("Storage error: {0}")]
StorageError(String),
#[error("Compression error: {0}")]
CompressionError(String),
#[error("IO error: {0}")]
IoError(#[from] std::io::Error),
#[error("Serialization error: {0}")]
SerializationError(String),
#[error("JSON error: {0}")]
JsonError(#[from] serde_json::Error),
#[error("Invalid checksum: expected {expected}, got {actual}")]
InvalidChecksum { expected: String, actual: String },
#[error("Collection error: {0}")]
CollectionError(String),
}
impl SnapshotError {
pub fn storage<S: Into<String>>(msg: S) -> Self {
SnapshotError::StorageError(msg.into())
}
pub fn corrupted<S: Into<String>>(msg: S) -> Self {
SnapshotError::CorruptedSnapshot(msg.into())
}
pub fn compression<S: Into<String>>(msg: S) -> Self {
SnapshotError::CompressionError(msg.into())
}
}