config: fix build on iOS for error set

This commit is contained in:
Mitchell Hashimoto
2024-08-18 19:31:36 -07:00
parent b79d80dc82
commit ea0e3057ca

View File

@ -34,14 +34,24 @@ pub const Location = enum {
break :user internal_os.xdg.config( break :user internal_os.xdg.config(
arena_alloc, arena_alloc,
.{ .subdir = subdir }, .{ .subdir = subdir },
) catch |err| switch (err) { ) catch |err| {
error.OutOfMemory => return error.OutOfMemory, // We need to do some comptime trick sot get the right
error.BufferTooSmall => return error.OutOfMemory, // error set since some platforms don't support some
// error types.
const Error = @TypeOf(err) || switch (builtin.os.tag) {
.ios => error{BufferTooSmall},
else => error{},
};
// Any other error we treat as the XDG directory not switch (@as(Error, err)) {
// existing. Windows in particularly can return a LOT error.OutOfMemory => return error.OutOfMemory,
// of errors here. error.BufferTooSmall => return error.OutOfMemory,
else => return null,
// Any other error we treat as the XDG directory not
// existing. Windows in particularly can return a LOT
// of errors here.
else => return null,
}
}; };
}, },