Add error message for Wepoll (#54)

* Add error message for Wepoll

* Avoid unsupported error kind where it is not supported
This commit is contained in:
John Nunley 2022-11-30 20:26:28 -08:00 committed by GitHub
parent 0b45549097
commit 00e7eefc4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -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");
}
}

View File

@ -42,7 +42,16 @@ impl Poller {
pub fn new() -> io::Result<Poller> {
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);