diff --git a/build.rs b/build.rs index 16d6db5..04923aa 100644 --- a/build.rs +++ b/build.rs @@ -18,4 +18,8 @@ fn main() { if !cfg.probe_rustc_version(1, 63) { autocfg::emit("polling_no_io_safety"); } + + if !cfg.probe_rustc_version(1, 53) { + autocfg::emit("polling_no_unsupported_error_kind"); + } } diff --git a/src/wepoll.rs b/src/wepoll.rs index 82cd241..f33d55e 100644 --- a/src/wepoll.rs +++ b/src/wepoll.rs @@ -42,7 +42,16 @@ impl Poller { pub fn new() -> io::Result { let handle = unsafe { we::epoll_create1(0) }; if handle.is_null() { - return Err(io::Error::last_os_error()); + return Err(io::Error::new( + #[cfg(not(polling_no_unsupported_error_kind))] + io::ErrorKind::Unsupported, + #[cfg(polling_no_unsupported_error_kind)] + io::ErrorKind::Other, + format!( + "Failed to initialize Wepoll: {}\nThis usually only happens for old Windows or Wine.", + io::Error::last_os_error() + ) + )); } let notified = AtomicBool::new(false); log::trace!("new: handle={:?}", handle);