diff options
author | syn <isaqtm@gmail.com> | 2020-02-09 19:17:57 +0300 |
---|---|---|
committer | syn <isaqtm@gmail.com> | 2020-02-09 19:17:57 +0300 |
commit | 30e1e3a13dc19c47afc517d1178e1dbf5b401596 (patch) | |
tree | b57b23cb10d468325bc259e05dfb6901b9b56f59 /src/wait/error.rs | |
parent | df090c4c8caa0632ce1fa802faf8752c2c861517 (diff) | |
download | evr-30e1e3a13dc19c47afc517d1178e1dbf5b401596.tar.gz |
timeout'ed waiter for process
Diffstat (limited to 'src/wait/error.rs')
-rw-r--r-- | src/wait/error.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/wait/error.rs b/src/wait/error.rs new file mode 100644 index 0000000..bb95e81 --- /dev/null +++ b/src/wait/error.rs @@ -0,0 +1,32 @@ +use nix; +use std::time::Duration; + +#[derive(Debug)] +pub enum WaitError { + TimedOut(Duration), + OsError(nix::Error) +} + +impl From<nix::Error> for WaitError { + fn from(err: nix::Error) -> Self { + WaitError::OsError(err) + } +} + +impl std::fmt::Display for WaitError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match *self { + WaitError::TimedOut(dur) => write!(f, "process timed out in {:?}", dur), + WaitError::OsError(err) => err.fmt(f) + } + } +} + +impl std::error::Error for WaitError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + match *self { + WaitError::TimedOut(_) => None, + WaitError::OsError(ref e) => Some(e) + } + } +}
\ No newline at end of file |