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

@@ -74,7 +74,7 @@ class ArticleThemesTableViewController: UITableViewController, Logging {
guard let cell = tableView.cellForRow(at: indexPath),
let themeName = cell.textLabel?.text else { return nil }
guard !ArticleThemesManager.shared.articleThemeWithThemeName(themeName).isAppTheme else { return nil }
guard let theme = try? ArticleThemesManager.shared.articleThemeWithThemeName(themeName), !theme.isAppTheme else { return nil }
let deleteTitle = NSLocalizedString("Delete", comment: "Delete")
let deleteAction = UIContextualAction(style: .normal, title: deleteTitle) { [weak self] (action, view, completion) in
@@ -114,12 +114,7 @@ extension ArticleThemesTableViewController: UIDocumentPickerDelegate {
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
guard let url = urls.first else { return }
do {
try ArticleThemeImporter.importTheme(controller: self, filename: url.standardizedFileURL.path)
} catch {
NotificationCenter.default.post(name: .didFailToImportThemeWithError, object: nil, userInfo: ["error": error])
logger.error("Did fail to import theme: \(error.localizedDescription, privacy: .public)")
}
try ArticleThemeImporter.importTheme(controller: self, filename: url.standardizedFileURL.path)
}
}