#[derive(Debug)]
#[non_exhaustive]
pub enum Error {
Notify(notify::Error),
Vcs(vcs_core::Error),
Io(std::io::Error),
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Error::Notify(e) => write!(f, "filesystem watch failed: {e}"),
Error::Vcs(e) => write!(f, "{e}"),
Error::Io(e) => write!(f, "{e}"),
}
}
}
impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
Error::Notify(e) => Some(e),
Error::Vcs(e) => Some(e),
Error::Io(e) => Some(e),
}
}
}
impl From<notify::Error> for Error {
fn from(e: notify::Error) -> Self {
Error::Notify(e)
}
}
impl From<vcs_core::Error> for Error {
fn from(e: vcs_core::Error) -> Self {
Error::Vcs(e)
}
}
impl From<std::io::Error> for Error {
fn from(e: std::io::Error) -> Self {
Error::Io(e)
}
}
pub type Result<T> = std::result::Result<T, Error>;