summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2021-02-04 22:49:41 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2021-02-04 22:49:41 +0100
commitda9fa7d1ad81528c60607f488f84155a3ecc3ee6 (patch)
tree4720d10ce33412440b64728d31b5060dcd6e1582
parent5bcba3f2e9db4aff6ca5859ee0fcb670656a4983 (diff)
downloadrebel-da9fa7d1ad81528c60607f488f84155a3ecc3ee6.tar
rebel-da9fa7d1ad81528c60607f488f84155a3ecc3ee6.zip
util: better ToIOResult
-rw-r--r--src/util.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/util.rs b/src/util.rs
index c18a263..4e996e8 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -11,7 +11,10 @@ pub trait ToIOResult<T> {
impl<T> ToIOResult<T> for nix::Result<T> {
fn to_io_result(self) -> Result<T> {
- self.map_err(|error| Error::new(ErrorKind::Other, error))
+ self.map_err(|error| match error {
+ nix::Error::Sys(code) => Error::from_raw_os_error(code as i32),
+ _ => Error::new(ErrorKind::Other, error),
+ })
}
}