git.lucas.co / cce-compositor
Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git

commit4b680b3e4c10461860abfe831368eef53663db63
parent35130c1f6b
authorLeon Henrik Plickat <[email protected]>
date2023-06-04 06:45
riverctl: Add error messages for failed connections

 riverctl/main.zig | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/riverctl/main.zig b/riverctl/main.zig
index b3861c3..80f6fb4 100644
--- a/riverctl/main.zig
+++ b/riverctl/main.zig
@@ -47,8 +47,6 @@ pub const Globals = struct {
 
 pub fn main() !void {
     _main() catch |err| {
-        if (builtin.mode == .Debug) return err;
-
         switch (err) {
             error.RiverControlNotAdvertised => fatal(
                 \\The Wayland server does not support river-control-unstable-v1.
@@ -57,6 +55,14 @@ pub fn main() !void {
             error.SeatNotAdverstised => fatal(
                 \\The Wayland server did not advertise any seat.
             , .{}),
+            error.ConnectFailed => {
+                std.log.err("Unable to connect to the Wayland server.", .{});
+                if (os.getenvZ("WAYLAND_DISPLAY") == null) {
+                    fatal("WAYLAND_DISPLAY is not set.", .{});
+                } else {
+                    fatal("Does WAYLAND_DISPLAY contain the socket name of a running server?", .{});
+                }
+            },
             else => return err,
         }
     };