diff --git a/Modules/Account/Sources/Account/Account.swift b/Modules/Account/Sources/Account/Account.swift index 4ef773829..8040d33b5 100644 --- a/Modules/Account/Sources/Account/Account.swift +++ b/Modules/Account/Sources/Account/Account.swift @@ -1126,7 +1126,7 @@ private extension Account { // MARK: - Credential Errors func postCredentialError(_ error: Error, operation: String, fileName: String = #fileID, functionName: String = #function, lineNumber: Int = #line) { - let errorLogUserInfo = ErrorLogUserInfoKey.userInfo(sourceName: nameForDisplay, sourceID: type.rawValue, operation: operation, errorMessage: error.localizedDescription, fileName: fileName, functionName: functionName, lineNumber: lineNumber) + let errorLogUserInfo = ErrorLogUserInfoKey.userInfo(sourceName: nameForDisplay, sourceID: type.rawValue, operation: operation, errorMessage: AccountError.detailedErrorMessage(error), fileName: fileName, functionName: functionName, lineNumber: lineNumber) NotificationCenter.default.post(name: .appDidEncounterError, object: self, userInfo: errorLogUserInfo) } diff --git a/Modules/Account/Sources/Account/AccountError.swift b/Modules/Account/Sources/Account/AccountError.swift index 053921fff..250693a14 100644 --- a/Modules/Account/Sources/Account/AccountError.swift +++ b/Modules/Account/Sources/Account/AccountError.swift @@ -94,13 +94,32 @@ public enum AccountError: LocalizedError { } } -// MARK: Private +// MARK: - Detailed Error Message + +extension AccountError { + + /// Returns a description that includes the error domain, code, and any underlying error. + static func detailedErrorMessage(_ error: Error) -> String { + let nsError = error as NSError + var message = error.localizedDescription + if !nsError.domain.isEmpty { + message += " (\(nsError.domain) \(nsError.code))" + } + if let underlyingError = nsError.userInfo[NSUnderlyingErrorKey] as? Error { + let underlyingNSError = underlyingError as NSError + message += " -- underlying: \(underlyingError.localizedDescription) (\(underlyingNSError.domain) \(underlyingNSError.code))" + } + return message + } +} + +// MARK: - Private private extension AccountError { func unknownError(_ error: Error, _ accountName: String) -> String { let localizedText = NSLocalizedString("An error occurred while processing the “%@” account: %@", comment: "Unknown error") - return NSString.localizedStringWithFormat(localizedText as NSString, accountName, error.localizedDescription) as String + return NSString.localizedStringWithFormat(localizedText as NSString, accountName, AccountError.detailedErrorMessage(error)) as String } func isCredentialsError(status: Int) -> Bool { diff --git a/Modules/Account/Sources/Account/AccountManager.swift b/Modules/Account/Sources/Account/AccountManager.swift index a194d2f36..545a69544 100644 --- a/Modules/Account/Sources/Account/AccountManager.swift +++ b/Modules/Account/Sources/Account/AccountManager.swift @@ -316,14 +316,10 @@ import ErrorLog await withTaskGroup(of: Void.self, isolation: MainActor.shared) { group in for account in activeAccounts { - let accountName = account.nameForDisplay - let accountTypeRawValue = account.type.rawValue group.addTask { do { try await account.refreshAll() } catch { - let errorLogUserInfo = ErrorLogUserInfoKey.userInfo(sourceName: accountName, sourceID: accountTypeRawValue, operation: "Refreshing", errorMessage: error.localizedDescription) - NotificationCenter.default.postOnMainThread(name: .appDidEncounterError, object: self, userInfo: errorLogUserInfo) errorHandler?(error) } } diff --git a/Modules/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift b/Modules/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift index c9d3bc04d..c44904ec7 100644 --- a/Modules/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift +++ b/Modules/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift @@ -217,7 +217,7 @@ enum CloudKitAccountDelegateError: LocalizedError, Sendable { try await accountZone.renameFeed(feed, editedName: editedName) feed.editedName = name } catch { - processAccountError(account, error, operation: "Renaming feed") + postSyncError(error, account: account, operation: "Renaming feed") throw error } } @@ -255,7 +255,7 @@ enum CloudKitAccountDelegateError: LocalizedError, Sendable { sourceContainer.removeFeedFromTreeAtTopLevel(feed) destinationContainer.addFeedToTreeAtTopLevel(feed) } catch { - processAccountError(account, error, operation: "Moving feed") + postSyncError(error, account: account, operation: "Moving feed") throw error } } @@ -272,7 +272,7 @@ enum CloudKitAccountDelegateError: LocalizedError, Sendable { try await accountZone.addFeed(feed, to: container) container.addFeedToTreeAtTopLevel(feed) } catch { - processAccountError(account, error, operation: "Adding feed") + postSyncError(error, account: account, operation: "Adding feed") throw error } } @@ -299,7 +299,7 @@ enum CloudKitAccountDelegateError: LocalizedError, Sendable { folder.externalID = externalID return folder } catch { - processAccountError(account, error, operation: "Creating folder") + postSyncError(error, account: account, operation: "Creating folder") throw error } } @@ -316,7 +316,7 @@ enum CloudKitAccountDelegateError: LocalizedError, Sendable { try await accountZone.renameFolder(folder, to: name) folder.name = name } catch { - processAccountError(account, error, operation: "Renaming folder") + postSyncError(error, account: account, operation: "Renaming folder") throw error } } @@ -335,7 +335,7 @@ enum CloudKitAccountDelegateError: LocalizedError, Sendable { } catch { syncProgress.completeTask() syncProgress.completeTask() - processAccountError(account, error, operation: "Removing folder") + postSyncError(error, account: account, operation: "Removing folder") throw error } @@ -424,7 +424,7 @@ enum CloudKitAccountDelegateError: LocalizedError, Sendable { account.addFolderToTree(folder) } catch { syncProgress.completeTask() - processAccountError(account, error, operation: "Restoring folder") + postSyncError(error, account: account, operation: "Restoring folder") throw error } } @@ -582,25 +582,43 @@ private extension CloudKitAccountDelegate { do { try await accountZone.fetchChangesInZone() syncProgress.completeTask() - - let feeds = account.flattenedFeeds() - - try await refreshArticleStatus(for: account) - syncProgress.completeTask() - - await refresher.refreshFeeds(feeds) - - if sendArticleStatus { - try await self.sendArticleStatus(account: account, showProgress: true) - } - - syncProgress.reset() - account.lastRefreshCompletedDate = Date() } catch { - processAccountError(account, error, operation: "Refreshing") + if case CloudKitZoneError.userDeletedZone = error { + account.removeFeedsFromTreeAtTopLevel(account.topLevelFeeds) + for folder in account.folders ?? Set() { + account.removeFolderFromTree(folder) + } + } + postSyncError(error, account: account, operation: "Fetching zone changes") syncProgress.reset() throw error } + + let feeds = account.flattenedFeeds() + + do { + try await refreshArticleStatus(for: account) + syncProgress.completeTask() + } catch { + postSyncError(error, account: account, operation: "Refreshing article status") + syncProgress.reset() + throw error + } + + await refresher.refreshFeeds(feeds) + + if sendArticleStatus { + do { + try await self.sendArticleStatus(account: account, showProgress: true) + } catch { + postSyncError(error, account: account, operation: "Sending article status") + syncProgress.reset() + throw error + } + } + + syncProgress.reset() + account.lastRefreshCompletedDate = Date() } func createRSSFeed(for account: Account, url: URL, editedName: String?, container: Container, validateFeed: Bool) async throws -> Feed { @@ -759,21 +777,8 @@ private extension CloudKitAccountDelegate { } } - func processAccountError(_ account: Account, _ error: Error, operation: String, fileName: String = #fileID, functionName: String = #function, lineNumber: Int = #line) { - if case CloudKitZoneError.userDeletedZone = error { - Self.logger.debug("CloudKitAccountDelegate: \(#function, privacy: .public) \(error)") - account.removeFeedsFromTreeAtTopLevel(account.topLevelFeeds) - for folder in account.folders ?? Set() { - account.removeFolderFromTree(folder) - } - Self.logger.debug("CloudKitAccountDelegate: \(#function, privacy: .public) did complete") - } else { - postSyncError(error, account: account, operation: operation, fileName: fileName, functionName: functionName, lineNumber: lineNumber) - } - } - func postSyncError(_ error: Error, account: Account, operation: String, fileName: String = #fileID, functionName: String = #function, lineNumber: Int = #line) { - let errorLogUserInfo = ErrorLogUserInfoKey.userInfo(sourceName: account.nameForDisplay, sourceID: account.type.rawValue, operation: operation, errorMessage: error.localizedDescription, fileName: fileName, functionName: functionName, lineNumber: lineNumber) + let errorLogUserInfo = ErrorLogUserInfoKey.userInfo(sourceName: account.nameForDisplay, sourceID: account.type.rawValue, operation: operation, errorMessage: AccountError.detailedErrorMessage(error), fileName: fileName, functionName: functionName, lineNumber: lineNumber) NotificationCenter.default.post(name: .appDidEncounterError, object: self, userInfo: errorLogUserInfo) } @@ -845,7 +850,7 @@ private extension CloudKitAccountDelegate { } catch { syncProgress.completeTask() syncProgress.completeTask() - processAccountError(account, error, operation: "Removing feed") + postSyncError(error, account: account, operation: "Removing feed") throw error } @@ -860,7 +865,7 @@ private extension CloudKitAccountDelegate { syncProgress.completeTask() } catch { syncProgress.completeTask() - processAccountError(account, error, operation: "Removing feed articles") + postSyncError(error, account: account, operation: "Removing feed articles") throw error } } diff --git a/Modules/Account/Sources/Account/CloudKit/CloudKitSendStatusOperation.swift b/Modules/Account/Sources/Account/CloudKit/CloudKitSendStatusOperation.swift index 8ba6aa9f4..b053dec90 100644 --- a/Modules/Account/Sources/Account/CloudKit/CloudKitSendStatusOperation.swift +++ b/Modules/Account/Sources/Account/CloudKit/CloudKitSendStatusOperation.swift @@ -101,7 +101,6 @@ final class CloudKitSendStatusOperation: MainThreadOperation, @unchecked Sendabl return false } catch { try? await syncDatabase.resetSelectedForProcessing(Set(syncStatuses.map({ $0.articleID }))) - processAccountError(account, error) syncErrorHandler?(error, "Sending article status", #fileID, #function, #line) Self.logger.error("iCloud: Send article status modify articles error: \(error.localizedDescription)") return true @@ -109,12 +108,4 @@ final class CloudKitSendStatusOperation: MainThreadOperation, @unchecked Sendabl } } - func processAccountError(_ account: Account, _ error: Error) { - if case CloudKitZoneError.userDeletedZone = error { - account.removeFeedsFromTreeAtTopLevel(account.topLevelFeeds) - for folder in account.folders ?? Set() { - account.removeFolderFromTree(folder) - } - } - } } diff --git a/Modules/Account/Sources/Account/Feedbin/FeedbinAccountDelegate.swift b/Modules/Account/Sources/Account/Feedbin/FeedbinAccountDelegate.swift index 29cc356a1..0de05ab2a 100644 --- a/Modules/Account/Sources/Account/Feedbin/FeedbinAccountDelegate.swift +++ b/Modules/Account/Sources/Account/Feedbin/FeedbinAccountDelegate.swift @@ -109,21 +109,26 @@ public enum FeedbinAccountDelegateError: String, Error, Sendable { Self.logger.info("Feedbin: Finished sending article statuses") } - guard let syncStatuses = try await syncDatabase.selectForProcessing() else { - return + do { + guard let syncStatuses = try await syncDatabase.selectForProcessing() else { + return + } + + let createUnreadStatuses = Array(syncStatuses.filter { $0.key == SyncStatus.Key.read && $0.flag == false }) + try await sendArticleStatuses(createUnreadStatuses, apiCall: caller.createUnreadEntries) + + let deleteUnreadStatuses = Array(syncStatuses.filter { $0.key == SyncStatus.Key.read && $0.flag == true }) + try await sendArticleStatuses(deleteUnreadStatuses, apiCall: caller.deleteUnreadEntries) + + let createStarredStatuses = Array(syncStatuses.filter { $0.key == SyncStatus.Key.starred && $0.flag == true }) + try await sendArticleStatuses(createStarredStatuses, apiCall: caller.createStarredEntries) + + let deleteStarredStatuses = Array(syncStatuses.filter { $0.key == SyncStatus.Key.starred && $0.flag == false }) + try await sendArticleStatuses(deleteStarredStatuses, apiCall: caller.deleteStarredEntries) + } catch { + postSyncError(error, account: account, operation: "Sending article status") + throw error } - - let createUnreadStatuses = Array(syncStatuses.filter { $0.key == SyncStatus.Key.read && $0.flag == false }) - try await sendArticleStatuses(createUnreadStatuses, apiCall: caller.createUnreadEntries) - - let deleteUnreadStatuses = Array(syncStatuses.filter { $0.key == SyncStatus.Key.read && $0.flag == true }) - try await sendArticleStatuses(deleteUnreadStatuses, apiCall: caller.deleteUnreadEntries) - - let createStarredStatuses = Array(syncStatuses.filter { $0.key == SyncStatus.Key.starred && $0.flag == true }) - try await sendArticleStatuses(createStarredStatuses, apiCall: caller.createStarredEntries) - - let deleteStarredStatuses = Array(syncStatuses.filter { $0.key == SyncStatus.Key.starred && $0.flag == false }) - try await sendArticleStatuses(deleteStarredStatuses, apiCall: caller.deleteStarredEntries) } func refreshArticleStatus(for account: Account) async throws { @@ -149,6 +154,7 @@ public enum FeedbinAccountDelegateError: String, Error, Sendable { Self.logger.info("Feedbin: Finished refreshing article statuses") if let refreshError { + postSyncError(refreshError, account: account, operation: "Refreshing article status") throw refreshError } } @@ -447,20 +453,25 @@ private extension FeedbinAccountDelegate { } func refreshAccount(_ account: Account) async throws { - let tags = try await caller.retrieveTags() - refreshProgress.completeTask() + do { + let tags = try await caller.retrieveTags() + refreshProgress.completeTask() - let subscriptions = try await caller.retrieveSubscriptions() - refreshProgress.completeTask() - forceExpireFolderFeedRelationship(account, tags) + let subscriptions = try await caller.retrieveSubscriptions() + refreshProgress.completeTask() + forceExpireFolderFeedRelationship(account, tags) - let taggings = try await caller.retrieveTaggings() - BatchUpdate.shared.perform { - syncFolders(account, tags) - syncFeeds(account, subscriptions) - syncFeedFolderRelationship(account, taggings) + let taggings = try await caller.retrieveTaggings() + BatchUpdate.shared.perform { + syncFolders(account, tags) + syncFeeds(account, subscriptions) + syncFeedFolderRelationship(account, taggings) + } + refreshProgress.completeTask() + } catch { + postSyncError(error, account: account, operation: "Refreshing account") + throw error } - refreshProgress.completeTask() } func refreshArticlesAndStatuses(_ account: Account) async throws { @@ -763,16 +774,21 @@ private extension FeedbinAccountDelegate { func refreshArticles(_ account: Account) async throws { Self.logger.info("Feedbin: Refreshing articles") - let (entries, page, updateFetchDate, lastPageNumber) = try await caller.retrieveEntries() + do { + let (entries, page, updateFetchDate, lastPageNumber) = try await caller.retrieveEntries() - if let last = lastPageNumber { - refreshProgress.addTasks(last - 1) + if let last = lastPageNumber { + refreshProgress.addTasks(last - 1) + } + + try await processEntries(account: account, entries: entries) + refreshProgress.completeTask() + + try await refreshArticles(account, page: page, updateFetchDate: updateFetchDate) + } catch { + postSyncError(error, account: account, operation: "Refreshing articles") + throw error } - - try await processEntries(account: account, entries: entries) - refreshProgress.completeTask() - - try await refreshArticles(account, page: page, updateFetchDate: updateFetchDate) } func refreshMissingArticles(_ account: Account) async throws { @@ -804,6 +820,7 @@ private extension FeedbinAccountDelegate { } if let savedError { + postSyncError(savedError, account: account, operation: "Refreshing missing articles") throw savedError } } @@ -943,7 +960,7 @@ private extension FeedbinAccountDelegate { } func postSyncError(_ error: Error, account: Account, operation: String, fileName: String = #fileID, functionName: String = #function, lineNumber: Int = #line) { - let errorLogUserInfo = ErrorLogUserInfoKey.userInfo(sourceName: account.nameForDisplay, sourceID: account.type.rawValue, operation: operation, errorMessage: error.localizedDescription, fileName: fileName, functionName: functionName, lineNumber: lineNumber) + let errorLogUserInfo = ErrorLogUserInfoKey.userInfo(sourceName: account.nameForDisplay, sourceID: account.type.rawValue, operation: operation, errorMessage: AccountError.detailedErrorMessage(error), fileName: fileName, functionName: functionName, lineNumber: lineNumber) NotificationCenter.default.post(name: .appDidEncounterError, object: self, userInfo: errorLogUserInfo) } } diff --git a/Modules/Account/Sources/Account/Feedly/FeedlyAccountDelegate.swift b/Modules/Account/Sources/Account/Feedly/FeedlyAccountDelegate.swift index 5e3afbb5c..aec31bb83 100644 --- a/Modules/Account/Sources/Account/Feedly/FeedlyAccountDelegate.swift +++ b/Modules/Account/Sources/Account/Feedly/FeedlyAccountDelegate.swift @@ -160,6 +160,8 @@ import Secrets if case .success = result { self?.accountSettings?.lastArticleFetchStartTime = date self?.accountSettings?.lastRefreshCompletedDate = Date() + } else if case .failure(let error) = result { + self?.postSyncError(error, account: account, operation: "Refreshing") } Self.logger.debug("FeedlyAccountDelegate: Sync took \(-date.timeIntervalSinceNow, privacy: .public) seconds") @@ -723,7 +725,7 @@ import Secrets private extension FeedlyAccountDelegate { func postSyncError(_ error: Error, account: Account, operation: String, fileName: String = #fileID, functionName: String = #function, lineNumber: Int = #line) { - let errorLogUserInfo = ErrorLogUserInfoKey.userInfo(sourceName: account.nameForDisplay, sourceID: account.type.rawValue, operation: operation, errorMessage: error.localizedDescription, fileName: fileName, functionName: functionName, lineNumber: lineNumber) + let errorLogUserInfo = ErrorLogUserInfoKey.userInfo(sourceName: account.nameForDisplay, sourceID: account.type.rawValue, operation: operation, errorMessage: AccountError.detailedErrorMessage(error), fileName: fileName, functionName: functionName, lineNumber: lineNumber) NotificationCenter.default.post(name: .appDidEncounterError, object: self, userInfo: errorLogUserInfo) } } diff --git a/Modules/Account/Sources/Account/LocalAccount/LocalAccountRefresher.swift b/Modules/Account/Sources/Account/LocalAccount/LocalAccountRefresher.swift index 9135221d0..011756cbd 100644 --- a/Modules/Account/Sources/Account/LocalAccount/LocalAccountRefresher.swift +++ b/Modules/Account/Sources/Account/LocalAccount/LocalAccountRefresher.swift @@ -210,7 +210,7 @@ import os let errorMessage = "HTTP \(statusCode) \(statusDescription): \(url.absoluteString)" let error = NSError(domain: "NetNewsWire", code: statusCode, userInfo: [NSLocalizedDescriptionKey: errorMessage]) - let errorLogUserInfo = ErrorLogUserInfoKey.userInfo(sourceName: account.nameForDisplay, sourceID: account.type.rawValue, operation: "Downloading feed", errorMessage: error.localizedDescription) + let errorLogUserInfo = ErrorLogUserInfoKey.userInfo(sourceName: account.nameForDisplay, sourceID: account.type.rawValue, operation: "Downloading feed", errorMessage: AccountError.detailedErrorMessage(error)) NotificationCenter.default.post(name: .appDidEncounterError, object: self, userInfo: errorLogUserInfo) } diff --git a/Modules/Account/Sources/Account/NewsBlur/Internals/NewsBlurAccountDelegate+Internal.swift b/Modules/Account/Sources/Account/NewsBlur/Internals/NewsBlurAccountDelegate+Internal.swift index 944c84d38..bfcf72cf8 100644 --- a/Modules/Account/Sources/Account/NewsBlur/Internals/NewsBlurAccountDelegate+Internal.swift +++ b/Modules/Account/Sources/Account/NewsBlur/Internals/NewsBlurAccountDelegate+Internal.swift @@ -21,7 +21,13 @@ import os @MainActor func refreshFeeds(for account: Account) async throws { Self.logger.info("NewsBlur: Refreshing feeds") - let (feeds, folders) = try await caller.retrieveFeeds() + let (feeds, folders): ([NewsBlurFeed]?, [NewsBlurFolder]?) + do { + (feeds, folders) = try await caller.retrieveFeeds() + } catch { + postSyncError(error, account: account, operation: "Refreshing feeds") + throw error + } BatchUpdate.shared.perform { MainActor.assumeIsolated { diff --git a/Modules/Account/Sources/Account/NewsBlur/NewsBlurAccountDelegate.swift b/Modules/Account/Sources/Account/NewsBlur/NewsBlurAccountDelegate.swift index 2a7ea0640..533953c61 100644 --- a/Modules/Account/Sources/Account/NewsBlur/NewsBlurAccountDelegate.swift +++ b/Modules/Account/Sources/Account/NewsBlur/NewsBlurAccountDelegate.swift @@ -155,6 +155,7 @@ import Secrets } if let savedError { + postSyncError(savedError, account: account, operation: "Sending article status") throw savedError } } @@ -184,6 +185,7 @@ import Secrets } if let savedError { + postSyncError(savedError, account: account, operation: "Refreshing article status") throw savedError } } @@ -486,7 +488,7 @@ import Secrets extension NewsBlurAccountDelegate { func postSyncError(_ error: Error, account: Account, operation: String, fileName: String = #fileID, functionName: String = #function, lineNumber: Int = #line) { - let errorLogUserInfo = ErrorLogUserInfoKey.userInfo(sourceName: account.nameForDisplay, sourceID: account.type.rawValue, operation: operation, errorMessage: error.localizedDescription, fileName: fileName, functionName: functionName, lineNumber: lineNumber) + let errorLogUserInfo = ErrorLogUserInfoKey.userInfo(sourceName: account.nameForDisplay, sourceID: account.type.rawValue, operation: operation, errorMessage: AccountError.detailedErrorMessage(error), fileName: fileName, functionName: functionName, lineNumber: lineNumber) NotificationCenter.default.post(name: .appDidEncounterError, object: self, userInfo: errorLogUserInfo) } } diff --git a/Modules/Account/Sources/Account/ReaderAPI/ReaderAPIAccountDelegate.swift b/Modules/Account/Sources/Account/ReaderAPI/ReaderAPIAccountDelegate.swift index 336b9af9e..64393e028 100644 --- a/Modules/Account/Sources/Account/ReaderAPI/ReaderAPIAccountDelegate.swift +++ b/Modules/Account/Sources/Account/ReaderAPI/ReaderAPIAccountDelegate.swift @@ -213,7 +213,9 @@ final class ReaderAPIAccountDelegate: AccountDelegate { } if errorOccurred { - throw AccountError.unknown + let error = AccountError.unknown + postSyncError(error, account: account, operation: "Refreshing article status") + throw error } } @@ -550,16 +552,21 @@ private extension ReaderAPIAccountDelegate { @MainActor func refreshAccount(_ account: Account) async throws { Self.logger.debug("ReaderAPIAccountDelegate: refreshAccount") - let tags = try await caller.retrieveTags() - refreshProgress.completeTask() + do { + let tags = try await caller.retrieveTags() + refreshProgress.completeTask() - let subscriptions = try await caller.retrieveSubscriptions() - refreshProgress.completeTask() + let subscriptions = try await caller.retrieveSubscriptions() + refreshProgress.completeTask() - BatchUpdate.shared.perform { - self.syncFolders(account, tags) - self.syncFeeds(account, subscriptions) - self.syncFeedFolderRelationship(account, subscriptions) + BatchUpdate.shared.perform { + self.syncFolders(account, tags) + self.syncFeeds(account, subscriptions) + self.syncFeedFolderRelationship(account, subscriptions) + } + } catch { + postSyncError(error, account: account, operation: "Refreshing account") + throw error } } @@ -951,7 +958,7 @@ private extension ReaderAPIAccountDelegate { } func postSyncError(_ error: Error, account: Account, operation: String, fileName: String = #fileID, functionName: String = #function, lineNumber: Int = #line) { - let errorLogUserInfo = ErrorLogUserInfoKey.userInfo(sourceName: account.nameForDisplay, sourceID: account.type.rawValue, operation: operation, errorMessage: error.localizedDescription, fileName: fileName, functionName: functionName, lineNumber: lineNumber) + let errorLogUserInfo = ErrorLogUserInfoKey.userInfo(sourceName: account.nameForDisplay, sourceID: account.type.rawValue, operation: operation, errorMessage: AccountError.detailedErrorMessage(error), fileName: fileName, functionName: functionName, lineNumber: lineNumber) NotificationCenter.default.post(name: .appDidEncounterError, object: self, userInfo: errorLogUserInfo) } } diff --git a/Modules/RSWeb/Sources/RSWeb/WebServices/Transport.swift b/Modules/RSWeb/Sources/RSWeb/WebServices/Transport.swift index 4453f019c..49f0a7fe1 100644 --- a/Modules/RSWeb/Sources/RSWeb/WebServices/Transport.swift +++ b/Modules/RSWeb/Sources/RSWeb/WebServices/Transport.swift @@ -107,8 +107,12 @@ public enum TransportError: LocalizedError, Sendable { let msg = NSLocalizedString("HTTP Status: ", comment: "Unexpected error") return "\(msg) \(status)" } - default: - return NSLocalizedString("An unknown network error occurred.", comment: "Unknown error") + case .noData: + return NSLocalizedString("No data was returned by the server.", comment: "No data") + case .noURL: + return NSLocalizedString("The URL for the request is missing.", comment: "No URL") + case .suspended: + return NSLocalizedString("The request was not sent because syncing is suspended.", comment: "Suspended") } } diff --git a/iOS/MainFeed/MainFeedCollectionViewController.swift b/iOS/MainFeed/MainFeedCollectionViewController.swift index d46aefabf..d8c5ee985 100644 --- a/iOS/MainFeed/MainFeedCollectionViewController.swift +++ b/iOS/MainFeed/MainFeedCollectionViewController.swift @@ -680,7 +680,7 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab } func setFilterButtonToInactive() { - filterButton.tintColor = nil + filterButton.tintColor = .label filterButton?.accLabelText = NSLocalizedString("Filter Read Feeds", comment: "Filter Read Feeds") } diff --git a/iOS/MainTimeline/MainTimelineModernViewController.swift b/iOS/MainTimeline/MainTimelineModernViewController.swift index 92ca1233a..db21f9d8b 100644 --- a/iOS/MainTimeline/MainTimelineModernViewController.swift +++ b/iOS/MainTimeline/MainTimelineModernViewController.swift @@ -620,33 +620,8 @@ extension MainTimelineModernViewController { return } - // Progress view group (flex, progress, flex) is inserted after the first toolbar item. - let progressViewInsertionIndex = 1 - let progressViewGroupCount = 3 - - let shouldShow = isSidebarHidden(for: displayMode) - - if shouldShow && !isToolbarProgressViewShowing { - guard var items = toolbarItems, !items.isEmpty else { - return - } - isToolbarProgressViewShowing = true - items.insert(UIBarButtonItem.flexibleSpace(), at: progressViewInsertionIndex) - items.insert(refreshBarItem, at: progressViewInsertionIndex + 1) - items.insert(UIBarButtonItem.flexibleSpace(), at: progressViewInsertionIndex + 2) - toolbarItems = items - } else if !shouldShow && isToolbarProgressViewShowing { - guard var items = toolbarItems, - let index = items.firstIndex(of: refreshBarItem) else { - return - } - isToolbarProgressViewShowing = false - // Remove the progress item and its flanking flex spaces - let rangeStart = max(index - 1, 0) - let rangeEnd = min(rangeStart + progressViewGroupCount - 1, items.count - 1) - items.removeSubrange(rangeStart...rangeEnd) - toolbarItems = items - } + isToolbarProgressViewShowing = isSidebarHidden(for: displayMode) + rebuildToolbarItems() } } @@ -910,10 +885,17 @@ private extension MainTimelineModernViewController { func configureToolbar() { if traitCollection.userInterfaceIdiom == .phone { if #available(iOS 26, *) { - toolbarItems?.insert(.flexibleSpace(), at: 1) - toolbarItems?.insert(navigationItem.searchBarPlacementBarButtonItem, at: 2) + if let markAllAsRead = toolbarItems?.first { + toolbarItems = [ + markAllAsRead, + .flexibleSpace(), + navigationItem.searchBarPlacementBarButtonItem, + .flexibleSpace(), + firstUnreadButton + ] + } } else { - // Remove storyboard placeholder flex spaces so the progress view centers correctly. + // Remove storyboard placeholder flex spaces so rebuildToolbarItems starts clean. if let markAllAsRead = toolbarItems?.first { toolbarItems = [markAllAsRead] } @@ -927,16 +909,10 @@ private extension MainTimelineModernViewController { navigationItem.rightBarButtonItem = shouldShowFilterButton ? filterButton : nil if isReadArticlesFiltered { - if #available(iOS 26, *) { - filterButton.style = .prominent - } else { - filterButton.style = .done - } filterButton.tintColor = Assets.Colors.primaryAccent filterButton.accLabelText = NSLocalizedString("Selected - Filter Read Articles", comment: "Selected - Filter Read Articles") } else { - filterButton.style = .plain - filterButton.tintColor = nil + filterButton.tintColor = .label filterButton.accLabelText = NSLocalizedString("Filter Read Articles", comment: "Filter Read Articles") } @@ -957,21 +933,31 @@ private extension MainTimelineModernViewController { func updateToolbar() { markAllAsReadButton?.isEnabled = isTimelineUnreadAvailable firstUnreadButton.isEnabled = coordinator?.isAnyUnreadAvailable ?? false - - if isRootSplitCollapsed { - if let toolbarItems = toolbarItems, toolbarItems.last != firstUnreadButton { - var items = toolbarItems - items.append(firstUnreadButton) - setToolbarItems(items, animated: false) - } - } else { - if let toolbarItems = toolbarItems, toolbarItems.last == firstUnreadButton { - let items = Array(toolbarItems[0.. Void)? = nil) { Self.logger.debug("MainTimelineModernViewController: applyChanges") guard let dataSource else {