use std::path::PathBuf;
use miette::Diagnostic;
use thiserror::Error;
#[derive(Debug, Diagnostic, Error)]
#[non_exhaustive]
pub enum FsWatcherError {
#[error("failed to instantiate")]
#[diagnostic(help("perhaps retry with the poll watcher"))]
Create(#[source] notify::Error),
#[error("failed to instantiate: too many watches")]
#[cfg_attr(target_os = "linux", diagnostic(help("you will want to increase your inotify.max_user_watches, see inotify(7) and https://watchexec.github.io/docs/inotify-limits.html")))]
#[cfg_attr(
not(target_os = "linux"),
diagnostic(help("this should not happen on your platform"))
)]
TooManyWatches(#[source] notify::Error),
#[error("failed to instantiate: too many handles")]
#[cfg_attr(target_os = "linux", diagnostic(help("you will want to increase your `nofile` limit, see pam_limits(8); or increase your inotify.max_user_instances, see inotify(7) and https://watchexec.github.io/docs/inotify-limits.html")))]
#[cfg_attr(
not(target_os = "linux"),
diagnostic(help("this should not happen on your platform"))
)]
TooManyHandles(#[source] notify::Error),
#[error("received an event that we could not read")]
Event(#[source] notify::Error),
#[error("while adding {path:?}")]
PathAdd {
path: PathBuf,
#[source]
err: notify::Error,
},
#[error("while removing {path:?}")]
PathRemove {
path: PathBuf,
#[source]
err: notify::Error,
},
}
#[derive(Debug, Diagnostic, Error)]
#[non_exhaustive]
pub enum KeyboardWatcherError {
#[error("failed to shut down stdin watcher")]
StdinShutdown,
}