use std::error::Error as _;
use std::io;
use vcs_watch::{Error, WatchError};
fn classify(err: &Error) {
if let Some(w) = err.watch_error() {
let _: bool = w.is_path_not_found();
let _: bool = w.is_watch_limit();
let _: Option<&io::Error> = w.io_error();
let _: &[std::path::PathBuf] = w.paths();
let _: Option<&(dyn std::error::Error + 'static)> = w.source();
}
if let Error::Notify(w) = err {
let _: &WatchError = w;
}
let mut source = err.source();
while let Some(e) = source {
source = e.source();
}
}
#[test]
fn error_is_classifiable_and_chainable_without_notify() {
let err = Error::from(io::Error::from(io::ErrorKind::PermissionDenied));
assert!(
err.watch_error().is_none(),
"an Io error is not a watch-backend error"
);
assert!(err.source().is_some(), "the std source is exposed");
classify(&err);
}