Commit ecf3857

Michael Sakaluk  ·  2026-03-12 23:02:53 -0400 EDT
parent 49b126a
fix: print error to stderr when session does not exist (#88)
1 files changed,  +10, -4
+10, -4
......@@ -884,8 +884,11 @@ fn kill(cfg: *Cfg, session_name: []const u8) !void {
884884
885885 const exists = try socket.sessionExists(dir, session_name);
886886 if (!exists) {
887- std.log.err("cannot kill session because it does not exist session_name={s}", .{session_name});
888- return;
887+ var buf: [4096]u8 = undefined;
888+ var w = std.fs.File.stderr().writer(&buf);
889+ w.interface.print("error: session \"{s}\" does not exist\n", .{session_name}) catch {};
890+ w.interface.flush() catch {};
891+ return error.SessionNotFound;
889892 }
890893
891894 const socket_path = try socket.getSocketPath(alloc, cfg.socket_dir, session_name);
......@@ -925,8 +928,11 @@ fn history(cfg: *Cfg, session_name: []const u8, format: util.HistoryFormat) !voi
925928
926929 const exists = try socket.sessionExists(dir, session_name);
927930 if (!exists) {
928- std.log.err("session does not exist session_name={s}", .{session_name});
929- return;
931+ var buf: [4096]u8 = undefined;
932+ var w = std.fs.File.stderr().writer(&buf);
933+ w.interface.print("error: session \"{s}\" does not exist\n", .{session_name}) catch {};
934+ w.interface.flush() catch {};
935+ return error.SessionNotFound;
930936 }
931937
932938 const socket_path = try socket.getSocketPath(alloc, cfg.socket_dir, session_name);