boots_core/
error.rs

1use std::fmt;
2
3#[derive(Debug)]
4pub enum BootsError {
5    AlreadyExists(String),
6    IoError(std::io::Error),
7    TemplateError(String),
8    Other(String),
9}
10
11impl fmt::Display for BootsError {
12    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
13        match self {
14            BootsError::AlreadyExists(path) => write!(f, "Already exists: {}", path),
15            BootsError::IoError(err) => write!(f, "IO error: {}", err),
16            BootsError::TemplateError(err) => write!(f, "Template error: {}", err),
17            BootsError::Other(err) => write!(f, "{}", err),
18        }
19    }
20}
21impl std::error::Error for BootsError {}
22
23impl From<std::io::Error> for BootsError {
24    fn from(err: std::io::Error) -> Self {
25        BootsError::IoError(err)
26    }
27}