1use std::io::ErrorKind;
2
3#[derive(Debug, thiserror::Error, PartialEq)]
5#[non_exhaustive]
6pub enum IOError {
7 #[error("Path not found: {0}")]
9 NotFound(String),
10
11 #[error("Permission denied: {0}")]
13 PermissionDenied(String),
14
15 #[error("Path already exists: {0}")]
17 AlreadyExists(String),
18
19 #[error("Timeout: {0}")]
21 TimedOut(String),
22
23 #[error("{0}")]
24 Other(String),
26}
27
28impl From<std::io::Error> for IOError {
29 fn from(value: std::io::Error) -> Self {
30 match value.kind() {
31 ErrorKind::NotFound => Self::NotFound(value.to_string()),
32 ErrorKind::PermissionDenied => Self::PermissionDenied(value.to_string()),
33 ErrorKind::AlreadyExists => Self::AlreadyExists(value.to_string()),
34 ErrorKind::TimedOut => Self::TimedOut(value.to_string()),
35 _ => Self::Other(value.to_string()),
36 }
37 }
38}