Change how we handle errors when working with Themes

This commit is contained in:
Maurice Parker
2022-11-08 01:36:28 -06:00
parent 97d740c41c
commit b7b9344e3d
9 changed files with 95 additions and 116 deletions

View File

@@ -56,15 +56,14 @@ extension AppDelegate : AppDelegateAppleEvents {
if let themeURL = URL(string: themeURLString) {
let request = URLRequest(url: themeURL)
let task = URLSession.shared.downloadTask(with: request) { [weak self] location, response, error in
guard let location = location else {
guard let self, let location else {
return
}
do {
try ArticleThemeDownloader.shared.handleFile(at: location)
} catch {
NotificationCenter.default.post(name: .didFailToImportThemeWithError, object: nil, userInfo: ["error": error])
self?.logger.error("Failed to import theme: \(error.localizedDescription, privacy: .public)")
self.presentThemeImportError(error)
}
}
task.resume()