Improve error when X11/Wayland is not present

This commit is contained in:
Diggory Hardy 2024-01-25 10:49:36 +00:00 committed by GitHub
parent b36d8d1e52
commit d0a1917603
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -765,10 +765,15 @@ impl<T: 'static> EventLoop<T> {
#[cfg(x11_platform)]
(None, _, true) => Backend::X,
// No backend is present.
_ => {
return Err(EventLoopError::Os(os_error!(OsError::Misc(
(_, wayland_display, x11_display) => {
let msg = if wayland_display && !cfg!(wayland_platform) {
"DISPLAY is not set; note: enable the `winit/wayland` feature to support Wayland"
} else if x11_display && !cfg!(x11_platform) {
"WAYLAND_DISPLAY is not set; note: enable the `winit/x11` feature to support X11"
} else {
"neither WAYLAND_DISPLAY nor DISPLAY is set."
))));
};
return Err(EventLoopError::Os(os_error!(OsError::Misc(msg))));
}
};