Split known create errors to get proper help text
This commit is contained in:
parent
3b64a41d80
commit
b77da446d8
|
@ -133,20 +133,38 @@ impl From<TaggedFiltererError> for RuntimeError {
|
||||||
#[diagnostic(url(docsrs))]
|
#[diagnostic(url(docsrs))]
|
||||||
pub enum FsWatcherError {
|
pub enum FsWatcherError {
|
||||||
/// Error received when creating a filesystem watcher fails.
|
/// Error received when creating a filesystem watcher fails.
|
||||||
|
///
|
||||||
|
/// Also see `TooManyWatches` and `TooManyHandles`.
|
||||||
#[error("failed to instantiate")]
|
#[error("failed to instantiate")]
|
||||||
#[diagnostic(
|
#[diagnostic(
|
||||||
code(watchexec::fs_watcher::create),
|
code(watchexec::fs_watcher::create),
|
||||||
help("perhaps retry with the poll watcher")
|
help("perhaps retry with the poll watcher")
|
||||||
)]
|
)]
|
||||||
Create {
|
Create(#[source] notify::Error),
|
||||||
/// The underlying error.
|
|
||||||
#[source]
|
|
||||||
err: notify::Error,
|
|
||||||
|
|
||||||
/// A hint to the user about resolving the error.
|
/// Error received when creating or updating a filesystem watcher fails because there are too many watches.
|
||||||
#[source_code]
|
///
|
||||||
help: String,
|
/// This is the OS error 28 on Linux.
|
||||||
},
|
#[error("failed to instantiate: too many watches")]
|
||||||
|
#[diagnostic(code(watchexec::fs_watcher::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 received when creating or updating a filesystem watcher fails because there are too many file handles open.
|
||||||
|
///
|
||||||
|
/// This is the OS error 24 on Linux. It may also occur when the limit for inotify instances is reached.
|
||||||
|
#[error("failed to instantiate: too many handles")]
|
||||||
|
#[diagnostic(code(watchexec::fs_watcher::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 when reading a filesystem event fails.
|
/// Error received when reading a filesystem event fails.
|
||||||
#[error("received an event that we could not read")]
|
#[error("received an event that we could not read")]
|
||||||
|
|
|
@ -53,16 +53,19 @@ impl Watcher {
|
||||||
}
|
}
|
||||||
.map_err(|err| RuntimeError::FsWatcher {
|
.map_err(|err| RuntimeError::FsWatcher {
|
||||||
kind: self,
|
kind: self,
|
||||||
err: FsWatcherError::Create {
|
err: if cfg!(target_os = "linux")
|
||||||
help: if cfg!(target_os = "linux") && (matches!(err.kind, notify::ErrorKind::MaxFilesWatch) || matches!(err.kind, notify::ErrorKind::Io(ref ioerr) if ioerr.raw_os_error() == Some(28))) {
|
&& (matches!(err.kind, notify::ErrorKind::MaxFilesWatch)
|
||||||
"you will want to increase your inotify.max_user_watches, see inotify(7) and https://watchexec.github.io/docs/inotify-limits.html"
|
|| matches!(err.kind, notify::ErrorKind::Io(ref ioerr) if ioerr.raw_os_error() == Some(28)))
|
||||||
} else if cfg!(target_os = "linux") && matches!(err.kind, notify::ErrorKind::Io(ref ioerr) if ioerr.raw_os_error() == Some(24)) {
|
{
|
||||||
"you will want to increase your `nofile` limit, see pam_limits(8)"
|
FsWatcherError::TooManyWatches(err)
|
||||||
|
} else if cfg!(target_os = "linux")
|
||||||
|
&& matches!(err.kind, notify::ErrorKind::Io(ref ioerr) if ioerr.raw_os_error() == Some(24))
|
||||||
|
{
|
||||||
|
FsWatcherError::TooManyHandles(err)
|
||||||
} else {
|
} else {
|
||||||
"you may want to try again with the polling watcher"
|
FsWatcherError::Create(err)
|
||||||
}.into(),
|
},
|
||||||
err,
|
})
|
||||||
}})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue