Skip to content

Commit

Permalink
refactor: improve error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
pylixonly committed Nov 9, 2024
1 parent 0b929c9 commit e0a0b79
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Sources/BunnyTweak/Tweak.x.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
}

0 comments on commit e0a0b79

Please sign in to comment.