1
use std::fmt;
2

            
3
/// Error type for cdup operations
4
#[derive(Debug)]
5
pub enum Error {
6
    /// Current working directory could not be determined
7
    InvalidCwd(std::io::Error),
8
    /// No fuzzy match found for the target
9
    NoMatch,
10
    /// Shell could not be detected
11
    ShellNotDetected,
12
}
13

            
14
impl fmt::Display for Error {
15
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
16
        match self {
17
            Error::InvalidCwd(_) => write!(f, "Could not get current working directory"),
18
            Error::NoMatch => write!(f, "No match found for target."),
19
            Error::ShellNotDetected => {
20
                write!(f, "No hint given and SHELL environment variable not found.")
21
            }
22
        }
23
    }
24
}
25

            
26
impl std::error::Error for Error {}