From ea0e3057caa154d81dd32f587d5e7a3aa2dae07a Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 18 Aug 2024 19:31:36 -0700 Subject: [PATCH] config: fix build on iOS for error set --- src/config/theme.zig | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/config/theme.zig b/src/config/theme.zig index aabf306ee..0054ae089 100644 --- a/src/config/theme.zig +++ b/src/config/theme.zig @@ -34,14 +34,24 @@ pub const Location = enum { break :user internal_os.xdg.config( arena_alloc, .{ .subdir = subdir }, - ) catch |err| switch (err) { - error.OutOfMemory => return error.OutOfMemory, - error.BufferTooSmall => return error.OutOfMemory, + ) catch |err| { + // We need to do some comptime trick sot get the right + // 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 - // existing. Windows in particularly can return a LOT - // of errors here. - else => return null, + switch (@as(Error, err)) { + error.OutOfMemory => return error.OutOfMemory, + error.BufferTooSmall => return error.OutOfMemory, + + // Any other error we treat as the XDG directory not + // existing. Windows in particularly can return a LOT + // of errors here. + else => return null, + } }; },