use std::io;
use thiserror::Error;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Error, Debug)]
#[non_exhaustive]
pub enum Error {
#[error("invalid exclude pattern: {0}")]
InvalidExclude(String),
#[error("I/O error: {0}")]
Io(#[from] io::Error),
#[cfg(feature = "walk")]
#[error("walk error: {0}")]
Walk(#[from] walkdir::Error),
#[cfg(feature = "watch")]
#[error("watch error: {0}")]
Watch(String),
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn io_errors_convert_via_from() {
let io_err = io::Error::new(io::ErrorKind::NotFound, "missing");
let err: Error = io_err.into();
assert!(matches!(err, Error::Io(_)));
}
#[test]
fn invalid_exclude_renders_message() {
let err = Error::InvalidExclude("`[unbalanced`: ...".into());
assert!(err.to_string().contains("invalid exclude"));
}
}