1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
use std::fmt::{Display, Formatter, Result}; use std::path::PathBuf; #[derive(Debug, Clone, PartialEq, Eq)] pub enum Error { CannotWriteFile { path: PathBuf, reason: String, }, CannotCreateDirectory { path: PathBuf, reason: String, }, GitError { reason: String, }, } impl Display for Error { fn fmt(&self, f: &mut Formatter<'_>) -> Result { match self { Self::CannotWriteFile { path, reason } => { write!(f, "unable to write file at {}: {}", path.display(), reason) } Self::CannotCreateDirectory { path, reason } => { write!(f, "unable to create directory at {}: {}", path.display(), reason) } Self::GitError { reason } => { write!(f, "an git error happened: {}", reason) } } } }