prompt: add proper error handling

This commit is contained in:
LordMZTE 2023-04-18 22:37:40 +02:00
parent 36d781da86
commit d62f635625
Signed by: LordMZTE
GPG key ID: B64802DC33A64FF6

View file

@ -24,7 +24,10 @@ pub fn main() !void {
const mode = FishMode.parse(std.mem.sliceTo(std.os.argv[3], 0));
var buf = std.BoundedArray(u8, 1024 * 8).init(0) catch unreachable;
try prompt.render(buf.writer(), status, mode);
prompt.render(buf.writer(), status, mode) catch |e| {
buf.resize(0) catch unreachable;
buf.writer().print("Render Error: {s}\n|> ", .{@errorName(e)}) catch unreachable;
};
try std.io.getStdOut().writeAll(buf.slice());
} else {
return error.UnknownCommand;