use thiserror::Error;
use crate::PathResolutionError;
#[derive(Debug, Error, PartialEq, Eq, Clone)]
#[repr(C)]
pub enum DfsFrontendError {
#[error("Operation not permitted on other nodes than files")]
NotAFile,
#[error("Operation not permitted on other nodes than directories")]
NotADirectory,
#[error("Path does not exist")]
NoSuchPath,
#[error(transparent)]
PathResolutionError(#[from] PathResolutionError),
#[error("Path already exists")]
PathAlreadyExists,
#[error("Parent of the provided path does not exist or is a file")]
InvalidParent,
#[error("Storages didn't respond: {0}")]
StorageNotResponsive(String),
#[error("Insufficient quota for uploading {0} bytes")]
InsufficientQuota(usize),
#[error("Operation could not modify read-only path")]
ReadOnlyPath,
#[error("Directory is not empty")]
DirNotEmpty,
#[error("DFS Error: {0}")]
Generic(String),
#[error("Source path and target path are in different Containers")]
MoveBetweenContainers,
#[error("The new pathname contained a path prefix of the old, or, more generally, an attempt was made to make a directory a subdirectory of itself.")]
SourceIsParentOfTarget,
#[error("Operation aborted")]
Aborted,
#[error("Operation not supported")]
NotSupported,
#[error("Path `{0}` exists in more than one container")]
PathConflict(String),
#[error("Encryptor Adapter Error: {0}")]
Encryption(String),
#[error("Permission error: {0}")]
PermissionError(String),
}
impl From<std::io::Error> for DfsFrontendError {
fn from(err: std::io::Error) -> Self {
DfsFrontendError::Generic(err.to_string())
}
}
impl From<anyhow::Error> for DfsFrontendError {
fn from(err: anyhow::Error) -> Self {
DfsFrontendError::Generic(err.to_string())
}
}