From e0a0b79507cc79fd816cd525a9a2c89f2fb65899 Mon Sep 17 00:00:00 2001 From: pylixonly <82711525+pylixonly@users.noreply.github.com> Date: Sat, 9 Nov 2024 16:16:08 +0800 Subject: [PATCH] refactor: improve error handling --- Sources/BunnyTweak/Tweak.x.swift | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Sources/BunnyTweak/Tweak.x.swift b/Sources/BunnyTweak/Tweak.x.swift index cde4f6b..f5d4ffe 100644 --- a/Sources/BunnyTweak/Tweak.x.swift +++ b/Sources/BunnyTweak/Tweak.x.swift @@ -130,14 +130,22 @@ struct BunnyTweak: Tweak { if let themeData = try? Data( contentsOf: pyoncordDirectory.appendingPathComponent("current-theme.json")) { let theme = try? JSONDecoder().decode(Theme.self, from: themeData) - if let semanticColors = theme?.data.semanticColors { swizzleDCDThemeColor(semanticColors) } - if let rawColors = theme?.data.rawColors { swizzleUIColor(rawColors) } + do { + if let semanticColors = theme?.data.semanticColors { try swizzleDCDThemeColor(semanticColors) } + if let rawColors = theme?.data.rawColors { try swizzleUIColor(rawColors) } + } catch { + os_log("Error swizzling colors", log: bunnyLog, type: .error) + } } if let fontData = try? Data( contentsOf: pyoncordDirectory.appendingPathComponent("fonts.json")) { let fonts = try? JSONDecoder().decode(FontDefinition.self, from: fontData) - if let main = fonts?.main { patchFonts(main, fontDefName: fonts!.name) } + do { + if let main = fonts?.main { patchFonts(main, fontDefName: fonts!.name) } + } catch { + os_log("Error patching fonts", log: bunnyLog, type: .error) + } } } }