feat: use explicit error handling for all startup errors
This commit is contained in:
parent
fc3224137d
commit
a1b2737c5d
12 changed files with 116 additions and 50 deletions
|
@ -8,13 +8,17 @@ const Plane = @import("renderer").Plane;
|
|||
|
||||
pub const Style = enum { none, grip };
|
||||
|
||||
pub fn create(allocator: std.mem.Allocator, parent: Plane, config: []const u8, style: Style, event_handler: ?EventHandler) !Widget {
|
||||
pub fn create(allocator: std.mem.Allocator, parent: Plane, config: []const u8, style: Style, event_handler: ?EventHandler) error{OutOfMemory}!Widget {
|
||||
var w = try WidgetList.createH(allocator, parent, "statusbar", .{ .static = 1 });
|
||||
if (style == .grip) w.after_render = render_grip;
|
||||
w.ctx = w;
|
||||
var it = std.mem.splitScalar(u8, config, ' ');
|
||||
while (it.next()) |widget_name|
|
||||
try w.add(try status_widget.create(widget_name, allocator, w.plane, event_handler) orelse continue);
|
||||
while (it.next()) |widget_name| {
|
||||
try w.add(status_widget.create(widget_name, allocator, w.plane, event_handler) catch |e| switch (e) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.WidgetInitFailed => null,
|
||||
} orelse continue);
|
||||
}
|
||||
return w.widget();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue