From 5ef9f52d959fdb935ffe914519e101a88c69348c Mon Sep 17 00:00:00 2001 From: Muaz Ahmad Date: Tue, 12 Dec 2023 14:55:31 +0500 Subject: [PATCH] added eof error since read does not raise errors for it --- src/main.zig | 9 ++++++++- src/util.zig | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main.zig b/src/main.zig index de05866..1a47ebe 100644 --- a/src/main.zig +++ b/src/main.zig @@ -65,5 +65,12 @@ pub fn main() !void { defer thread_manager.deinit(); var f = std.io.getStdIn(); - try input.main_loop(f, buffs, &thread_manager, std.heap.page_allocator); + input.main_loop(f, buffs, &thread_manager, std.heap.page_allocator) catch |err| { + switch (err) { + util.Errors.EOFError => { + return; + }, + else => return err, + } + }; } diff --git a/src/util.zig b/src/util.zig index e8473e9..ddb5b2e 100644 --- a/src/util.zig +++ b/src/util.zig @@ -1,5 +1,9 @@ const std = @import("std"); +pub const Errors = error{ + EOFError, +}; + pub const Options = struct { width: usize, height: usize,