summaryrefslogtreecommitdiffstats
path: root/src/util.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.rs')
-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),
+ })
}
}