Skip to content

Commit

Permalink
Display correct error on max-files-watch
Browse files Browse the repository at this point in the history
See #266

Signed-off-by: Aron Heinecke <aron.heinecke@t-online.de>
  • Loading branch information
0xpr03 committed Mar 11, 2021
1 parent b096b62 commit 32fd34f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ pub enum ErrorKind {

/// An invalid value was passed as runtime configuration.
InvalidConfig(Config),

/// Can't watch (more) files, limit on the total number of inotify watches reached
MaxFilesWatch,
}

/// Notify error type.
Expand Down Expand Up @@ -75,6 +78,11 @@ impl Error {

/// Creates a new i/o Error from a stdlib `io::Error`.
pub fn io(err: io::Error) -> Self {
// do not report inotify limits as "no more space" on linux #266
#[cfg(target_os = "linux")]
if err.raw_os_error() == Some(28) {
return Self::new(ErrorKind::MaxFilesWatch);
}
Self::new(ErrorKind::Io(err))
}

Expand Down Expand Up @@ -102,6 +110,7 @@ impl fmt::Display for Error {
ErrorKind::InvalidConfig(ref config) => format!("Invalid configuration: {:?}", config),
ErrorKind::Generic(ref err) => err.clone(),
ErrorKind::Io(ref err) => err.to_string(),
ErrorKind::MaxFilesWatch => "OS file watch limit reached.".into(),
};

if self.paths.is_empty() {
Expand Down

0 comments on commit 32fd34f

Please sign in to comment.