diff --git a/src/buffer/Buffer.zig b/src/buffer/Buffer.zig index b4a64a4..ee60656 100644 --- a/src/buffer/Buffer.zig +++ b/src/buffer/Buffer.zig @@ -966,7 +966,7 @@ pub fn load(self: *const Self, reader: anytype, size: usize) !Root { return error.BufferUnderrun; const final_read = try reader.read(buf); if (final_read != 0) - unreachable; + @panic("unexpected data in final read"); var leaf_count: usize = 1; for (0..buf.len) |i| { diff --git a/src/project_manager.zig b/src/project_manager.zig index 4beb7c6..466c9b9 100644 --- a/src/project_manager.zig +++ b/src/project_manager.zig @@ -272,7 +272,7 @@ const FilteredWalker = struct { if (is_filtered_dir(base.name)) continue; var new_dir = top.iter.dir.openDir(base.name, .{ .iterate = true }) catch |err| switch (err) { - error.NameTooLong => unreachable, // no path sep in base.name + error.NameTooLong => @panic("unexpected error.NameTooLong"), // no path sep in base.name else => continue, }; { diff --git a/src/tui/EventHandler.zig b/src/tui/EventHandler.zig index e2ab0e2..f4c1969 100644 --- a/src/tui/EventHandler.zig +++ b/src/tui/EventHandler.zig @@ -157,7 +157,7 @@ pub const List = struct { pub fn send(self: *const List, from: tp.pid_ref, m: tp.message) tp.result { if (self.recursion_check) - unreachable; + @panic("recursive EventHandler call"); const self_nonconst = @constCast(self); self_nonconst.recursion_check = true; defer self_nonconst.recursion_check = false; diff --git a/src/tui/command.zig b/src/tui/command.zig index a24d8db..97f8412 100644 --- a/src/tui/command.zig +++ b/src/tui/command.zig @@ -10,7 +10,7 @@ pub const Context = struct { args: tp.message = .{}, pub fn fmt(value: anytype) Context { - return .{ .args = tp.message.fmtbuf(&context_buffer, value) catch unreachable }; + return .{ .args = tp.message.fmtbuf(&context_buffer, value) catch @panic("command.Context.fmt failed") }; } }; threadlocal var context_buffer: [tp.max_message_size]u8 = undefined; diff --git a/src/tui/editor.zig b/src/tui/editor.zig index 2b0a534..82f3f1d 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -409,7 +409,9 @@ pub const Editor = struct { return primary; if (idx == 0) { self.logger.print("ERROR: no more cursors", .{}); - (@constCast(self).cursels.addOne() catch unreachable).* = CurSel{}; + (@constCast(self).cursels.addOne() catch |e| switch (e) { + error.OutOfMemory => @panic("get_primary error.OutOfMemory"), + }).* = CurSel{}; } return self.get_primary(); } @@ -2770,7 +2772,7 @@ pub const Editor = struct { if (query.len == 0) return; const history = if (self.find_history) |*hist| hist else ret: { self.find_history = std.ArrayList([]const u8).init(self.a); - if (self.find_history) |*hist| break :ret hist else unreachable; + break :ret &self.find_history.?; }; for (history.items, 0..) |entry, i| if (std.mem.eql(u8, entry, query)) diff --git a/src/tui/home.zig b/src/tui/home.zig index 9628145..649f98f 100644 --- a/src/tui/home.zig +++ b/src/tui/home.zig @@ -150,7 +150,7 @@ pub fn render(self: *Self, theme: *const Widget.Theme) bool { try tui.set_base_style_alpha(self.plane, "", theme.editor, nc.ALPHA_TRANSPARENT, nc.ALPHA_TRANSPARENT); self.plane.erase(); self.plane.home(); - if (self.fire) |*fire| fire.render() catch unreachable; + if (self.fire) |*fire| fire.render(); const style_title = if (tui.find_scope_style(theme, "function")) |sty| sty.style else theme.editor; const style_subtext = if (tui.find_scope_style(theme, "comment")) |sty| sty.style else theme.editor; @@ -199,7 +199,7 @@ pub fn handle_resize(self: *Self, pos: Widget.Box) void { self.plane.resize_simple(@intCast(pos.h), @intCast(pos.w)) catch return; if (self.fire) |*fire| { fire.deinit(); - self.fire = Fire.init(self.a, self.plane, pos) catch unreachable; + self.fire = Fire.init(self.a, self.plane, pos) catch return; } } @@ -278,7 +278,7 @@ const Fire = struct { const fire_black: u8 = 0; const fire_white: u8 = fire_palette.len - 1; - fn render(self: *Fire) !void { + fn render(self: *Fire) void { var rand = self.prng.random(); //update fire buf @@ -328,9 +328,9 @@ const Fire = struct { const px_hi = self.screen_buf[frame_y * self.FIRE_W + frame_x]; const px_lo = self.screen_buf[(frame_y + 1) * self.FIRE_W + frame_x]; - try self.plane.set_fg_palindex(fire_palette[px_hi]); - try self.plane.set_bg_palindex(fire_palette[px_lo]); - _ = try self.plane.putstr(px); + self.plane.set_fg_palindex(fire_palette[px_hi]) catch {}; + self.plane.set_bg_palindex(fire_palette[px_lo]) catch {}; + _ = self.plane.putstr(px) catch {}; } self.plane.cursor_move_yx(-1, 0) catch {}; self.plane.cursor_move_rel(1, 0) catch {}; diff --git a/src/tui/mainview.zig b/src/tui/mainview.zig index 035db41..997e833 100644 --- a/src/tui/mainview.zig +++ b/src/tui/mainview.zig @@ -335,10 +335,10 @@ fn create_editor(self: *Self) tp.result { var editor_widget = ed.create(self.a, Widget.to(self)) catch |e| return tp.exit_error(e); errdefer editor_widget.deinit(self.a); if (editor_widget.get("editor")) |editor| { - editor.subscribe(EventHandler.to_unowned(self.statusbar)) catch unreachable; - editor.subscribe(EventHandler.bind(self, handle_editor_event)) catch unreachable; + editor.subscribe(EventHandler.to_unowned(self.statusbar)) catch @panic("subscribe unsupported"); + editor.subscribe(EventHandler.bind(self, handle_editor_event)) catch @panic("subscribe unsupported"); self.editor = if (editor.dynamic_cast(ed.EditorWidget)) |p| &p.editor else null; - } else unreachable; + } else @panic("mainview editor not found"); self.widgets.replace(0, editor_widget); self.resize(); }