Skip to content

Commit

Permalink
Improve error when X11/Wayland is not present
Browse files Browse the repository at this point in the history
  • Loading branch information
dhardy authored Jan 25, 2024
1 parent b36d8d1 commit d0a1917
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/platform_impl/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))));
}
};

Expand Down

0 comments on commit d0a1917

Please sign in to comment.