use std::io::ErrorKind;
#[derive(Debug, thiserror::Error, PartialEq)]
#[non_exhaustive]
pub enum IOError {
#[error("Path not found: {0}")]
NotFound(String),
#[error("Permission denied: {0}")]
PermissionDenied(String),
#[error("Path already exists: {0}")]
AlreadyExists(String),
#[error("Timeout: {0}")]
TimedOut(String),
#[error("{0}")]
Other(String),
}
impl From<std::io::Error> for IOError {
fn from(value: std::io::Error) -> Self {
match value.kind() {
ErrorKind::NotFound => Self::NotFound(value.to_string()),
ErrorKind::PermissionDenied => Self::PermissionDenied(value.to_string()),
ErrorKind::AlreadyExists => Self::AlreadyExists(value.to_string()),
ErrorKind::TimedOut => Self::TimedOut(value.to_string()),
_ => Self::Other(value.to_string()),
}
}
}