use bevy::utils::thiserror::Error;
use pathio::PathioError;
#[derive(Debug, Error)]
pub enum LunexError {
#[error("Container from merging branch was not dropped before merging")]
ContainerConflict,
#[error("Duplicate name conflict for '{0:}' when trying to merge directory")]
DuplicateName (String),
#[error("Name '{0:}' is already in use")]
NameInUse (String),
#[error("Path '{0:}' is not allowed")]
InvalidPath (String),
#[error("Unable to locate '{0:}' branch")]
NoBranch (String),
#[error("could not find '{path:}': {cause:}")]
FetchError {
path: String,
cause: Box<LunexError>,
},
}
impl From<PathioError> for LunexError {
fn from(value: PathioError) -> Self {
match value {
PathioError::FileConflict => LunexError::ContainerConflict,
PathioError::DuplicateName (v) => LunexError::DuplicateName (v),
PathioError::NameInUse (v) => LunexError::NameInUse (v),
PathioError::NoDirectory (v) => LunexError::NoBranch (v),
PathioError::NoFile (_) => panic!("API should NOT ALLOW you to get this error"),
PathioError::InvalidPath (v) => LunexError::InvalidPath (v),
}
}
}