code: improve error handling consistency

This commit is contained in:
Isaac Freund
2020-06-26 00:59:31 +02:00
parent 8fc045b445
commit 79bb0accac
11 changed files with 23 additions and 40 deletions

View File

@ -36,11 +36,10 @@ var river_control_optional: ?*c.zriver_control_v1 = null;
var wl_seat_optional: ?*c.wl_seat = null;
pub fn main() !void {
const wl_display = c.wl_display_connect(null) orelse return error.CantConnectToDisplay;
const wl_display = c.wl_display_connect(null) orelse return error.ConnectError;
const wl_registry = c.wl_display_get_registry(wl_display);
if (c.wl_registry_add_listener(wl_registry, &wl_registry_listener, null) < 0)
return error.FailedToAddListener;
if (c.wl_registry_add_listener(wl_registry, &wl_registry_listener, null) < 0) unreachable;
if (c.wl_display_roundtrip(wl_display) < 0) return error.RoundtripFailed;
const river_control = river_control_optional orelse return error.RiverControlNotAdvertised;
@ -56,7 +55,7 @@ pub fn main() !void {
command_callback,
&command_callback_listener,
null,
) < 0) return error.FailedToAddListener;
) < 0) unreachable;
// Loop until our callback is called and we exit.
while (true) if (c.wl_display_dispatch(wl_display) < 0) return error.DispatchFailed;