fix: no logner crashes when config directory is missing
This commit is contained in:
parent
10ae6933ba
commit
4cc0ba139a
|
@ -24,14 +24,16 @@ pub const Config = struct {
|
|||
) catch break :toml orelse break :toml;
|
||||
defer config_dir.close();
|
||||
|
||||
const config = try config_dir.realpathAlloc(alloc, "gpower2/config.toml");
|
||||
const config = config_dir.realpathAlloc(alloc, "gpower2/config.toml") catch {
|
||||
std.log.warn("Couldn't open config directory, skipping config", .{});
|
||||
break :toml;
|
||||
};
|
||||
defer alloc.free(config);
|
||||
const config_z = try std.cstr.addNullByte(alloc, config);
|
||||
defer alloc.free(config_z);
|
||||
|
||||
const c_file = c.fopen(config_z, "r");
|
||||
|
||||
std.log.debug("{x}", .{@ptrToInt(c_file)});
|
||||
if (c_file == null) {
|
||||
std.log.warn("Opening config failed, skipping config", .{});
|
||||
break :toml;
|
||||
|
|
Loading…
Reference in New Issue