use std::io;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum Error {
#[error("File not found: {0}")]
NotFound(String),
#[error("Permission denied: {0}")]
PermissionDenied(String),
#[error("IO error: {0}")]
Io(#[from] io::Error),
#[error("Invalid path: {0}")]
InvalidPath(String),
#[error("Disk not configured: {0}")]
DiskNotConfigured(String),
#[cfg(feature = "s3")]
#[error("S3 error: {0}")]
S3(String),
#[error("Not implemented: {0}")]
NotImplemented(String),
#[error("Serialization error: {0}")]
Serialization(String),
}
impl Error {
pub fn not_found(path: impl Into<String>) -> Self {
Self::NotFound(path.into())
}
pub fn permission_denied(msg: impl Into<String>) -> Self {
Self::PermissionDenied(msg.into())
}
pub fn invalid_path(path: impl Into<String>) -> Self {
Self::InvalidPath(path.into())
}
pub fn disk_not_configured(disk: impl Into<String>) -> Self {
Self::DiskNotConfigured(disk.into())
}
pub fn not_implemented(feature: impl Into<String>) -> Self {
Self::NotImplemented(feature.into())
}
}