From da9fa7d1ad81528c60607f488f84155a3ecc3ee6 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 4 Feb 2021 22:49:41 +0100 Subject: util: better ToIOResult --- src/util.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 { impl ToIOResult for nix::Result { fn to_io_result(self) -> Result { - 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), + }) } } -- cgit v1.2.3