1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/// Everything that stops a jeans command. The CLI prints it after `jeans: `.
#[derive(Debug, thiserror::Error)]
pub enum Error {
    #[error("{0}")]
    Message(String),
    #[error(transparent)]
    Io(#[from] std::io::Error),
    #[error("jj printed output that isn't UTF-8: {0}")]
    Utf8(#[from] std::string::FromUtf8Error),
    #[error("{} isn't a UTF-8 path", .0.as_path().display())]
    Path(#[from] camino::FromPathBufError),
}

pub type Result<T> = std::result::Result<T, Error>;

impl Error {
    pub(crate) fn msg(message: impl Into<String>) -> Self {
        Self::Message(message.into())
    }
}