diff --git a/CHANGELOG.md b/CHANGELOG.md index e5eb0c6..e267eff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## Unreleased +## 0.2.0 + +- Add `std::error::Error` trait to `CmdError` () + ## 0.1.3 - Update docs on crates.io (https://github.com/schneems/fun_run/pull/7) diff --git a/src/lib.rs b/src/lib.rs index abb6eaf..14c863e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -356,6 +356,15 @@ impl Display for CmdError { } } +impl std::error::Error for CmdError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + match self { + CmdError::SystemError(_, io_err) => Some(io_err), + CmdError::NonZeroExitNotStreamed(_) | CmdError::NonZeroExitAlreadyStreamed(_) => None, + } + } +} + impl CmdError { /// Returns a display representation of the command that failed ///