From da58db393151cebfbda44ab3da93f82b825a2a92 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Tue, 31 Mar 2026 18:05:04 -0700 Subject: [PATCH 1/6] Add more specific error messages. --- Modules/RSWeb/Sources/RSWeb/WebServices/Transport.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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") } } From b8cd5f564c1ad9bd6f1a3fb0b148573abd52bd4c Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Tue, 31 Mar 2026 18:06:05 -0700 Subject: [PATCH 2/6] =?UTF-8?q?Report=20more=20detailed=20error=20messages?= =?UTF-8?q?=20=E2=80=94=C2=A0create=20and=20use=20AccountError.detailedErr?= =?UTF-8?q?orMessage.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Modules/Account/Sources/Account/Account.swift | 2 +- .../Sources/Account/AccountError.swift | 23 +++++++++++++++++-- .../Sources/Account/AccountManager.swift | 2 +- .../CloudKit/CloudKitAccountDelegate.swift | 2 +- .../Feedbin/FeedbinAccountDelegate.swift | 2 +- .../Feedly/FeedlyAccountDelegate.swift | 2 +- .../LocalAccount/LocalAccountRefresher.swift | 2 +- .../NewsBlur/NewsBlurAccountDelegate.swift | 2 +- .../ReaderAPI/ReaderAPIAccountDelegate.swift | 2 +- 9 files changed, 29 insertions(+), 10 deletions(-) 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..7d00943a7 100644 --- a/Modules/Account/Sources/Account/AccountManager.swift +++ b/Modules/Account/Sources/Account/AccountManager.swift @@ -322,7 +322,7 @@ import ErrorLog do { try await account.refreshAll() } catch { - let errorLogUserInfo = ErrorLogUserInfoKey.userInfo(sourceName: accountName, sourceID: accountTypeRawValue, operation: "Refreshing", errorMessage: error.localizedDescription) + let errorLogUserInfo = ErrorLogUserInfoKey.userInfo(sourceName: accountName, sourceID: accountTypeRawValue, operation: "Refreshing", errorMessage: AccountError.detailedErrorMessage(error)) 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..b6c9e5875 100644 --- a/Modules/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift +++ b/Modules/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift @@ -773,7 +773,7 @@ private extension CloudKitAccountDelegate { } 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/Feedbin/FeedbinAccountDelegate.swift b/Modules/Account/Sources/Account/Feedbin/FeedbinAccountDelegate.swift index 29cc356a1..960b2bbb7 100644 --- a/Modules/Account/Sources/Account/Feedbin/FeedbinAccountDelegate.swift +++ b/Modules/Account/Sources/Account/Feedbin/FeedbinAccountDelegate.swift @@ -943,7 +943,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..a1888918f 100644 --- a/Modules/Account/Sources/Account/Feedly/FeedlyAccountDelegate.swift +++ b/Modules/Account/Sources/Account/Feedly/FeedlyAccountDelegate.swift @@ -723,7 +723,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/NewsBlurAccountDelegate.swift b/Modules/Account/Sources/Account/NewsBlur/NewsBlurAccountDelegate.swift index 2a7ea0640..7ed3679bf 100644 --- a/Modules/Account/Sources/Account/NewsBlur/NewsBlurAccountDelegate.swift +++ b/Modules/Account/Sources/Account/NewsBlur/NewsBlurAccountDelegate.swift @@ -486,7 +486,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..64b612d27 100644 --- a/Modules/Account/Sources/Account/ReaderAPI/ReaderAPIAccountDelegate.swift +++ b/Modules/Account/Sources/Account/ReaderAPI/ReaderAPIAccountDelegate.swift @@ -951,7 +951,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) } } From 0c2808e607bc2fefc4231782188c0f60dd023636 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Tue, 31 Mar 2026 18:36:23 -0700 Subject: [PATCH 3/6] Post error notifications close to where they happen, which gives us more detail about what went wrong. --- .../Sources/Account/AccountManager.swift | 4 - .../CloudKit/CloudKitAccountDelegate.swift | 42 ++++++---- .../Feedbin/FeedbinAccountDelegate.swift | 83 +++++++++++-------- .../Feedly/FeedlyAccountDelegate.swift | 2 + .../NewsBlurAccountDelegate+Internal.swift | 8 +- .../NewsBlur/NewsBlurAccountDelegate.swift | 2 + .../ReaderAPI/ReaderAPIAccountDelegate.swift | 25 ++++-- 7 files changed, 104 insertions(+), 62 deletions(-) diff --git a/Modules/Account/Sources/Account/AccountManager.swift b/Modules/Account/Sources/Account/AccountManager.swift index 7d00943a7..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: AccountError.detailedErrorMessage(error)) - 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 b6c9e5875..38de80c40 100644 --- a/Modules/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift +++ b/Modules/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift @@ -582,25 +582,37 @@ 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") + processAccountError(account, error, operation: "Fetching zone changes") syncProgress.reset() throw error } + + let feeds = account.flattenedFeeds() + + do { + try await refreshArticleStatus(for: account) + syncProgress.completeTask() + } catch { + processAccountError(account, error, operation: "Refreshing article status") + syncProgress.reset() + throw error + } + + await refresher.refreshFeeds(feeds) + + if sendArticleStatus { + do { + try await self.sendArticleStatus(account: account, showProgress: true) + } catch { + processAccountError(account, error, 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 { diff --git a/Modules/Account/Sources/Account/Feedbin/FeedbinAccountDelegate.swift b/Modules/Account/Sources/Account/Feedbin/FeedbinAccountDelegate.swift index 960b2bbb7..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 } } diff --git a/Modules/Account/Sources/Account/Feedly/FeedlyAccountDelegate.swift b/Modules/Account/Sources/Account/Feedly/FeedlyAccountDelegate.swift index a1888918f..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") 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 7ed3679bf..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 } } diff --git a/Modules/Account/Sources/Account/ReaderAPI/ReaderAPIAccountDelegate.swift b/Modules/Account/Sources/Account/ReaderAPI/ReaderAPIAccountDelegate.swift index 64b612d27..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 } } From cdefbbf7e23d4ae5d7b9da2028ad4ec5cdcf2d50 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Tue, 31 Mar 2026 20:53:11 -0700 Subject: [PATCH 4/6] Call postSyncError like all the other account delegates. --- .../CloudKit/CloudKitAccountDelegate.swift | 43 ++++++++----------- .../CloudKitSendStatusOperation.swift | 9 ---- 2 files changed, 18 insertions(+), 34 deletions(-) diff --git a/Modules/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift b/Modules/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift index 38de80c40..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 } } @@ -583,7 +583,13 @@ private extension CloudKitAccountDelegate { try await accountZone.fetchChangesInZone() syncProgress.completeTask() } catch { - processAccountError(account, error, operation: "Fetching zone changes") + 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 } @@ -594,7 +600,7 @@ private extension CloudKitAccountDelegate { try await refreshArticleStatus(for: account) syncProgress.completeTask() } catch { - processAccountError(account, error, operation: "Refreshing article status") + postSyncError(error, account: account, operation: "Refreshing article status") syncProgress.reset() throw error } @@ -605,7 +611,7 @@ private extension CloudKitAccountDelegate { do { try await self.sendArticleStatus(account: account, showProgress: true) } catch { - processAccountError(account, error, operation: "Sending article status") + postSyncError(error, account: account, operation: "Sending article status") syncProgress.reset() throw error } @@ -771,19 +777,6 @@ 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: AccountError.detailedErrorMessage(error), fileName: fileName, functionName: functionName, lineNumber: lineNumber) NotificationCenter.default.post(name: .appDidEncounterError, object: self, userInfo: errorLogUserInfo) @@ -857,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 } @@ -872,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) - } - } - } } From 3dfaf3e707ff687b6933d25f89b3e57f852c5cb0 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Wed, 1 Apr 2026 10:10:44 -0700 Subject: [PATCH 5/6] Normalize filter button status display between sidebar and timeline and across iOS 17/18/26. --- iOS/MainFeed/MainFeedCollectionViewController.swift | 2 +- iOS/MainTimeline/MainTimelineModernViewController.swift | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) 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..51db1762e 100644 --- a/iOS/MainTimeline/MainTimelineModernViewController.swift +++ b/iOS/MainTimeline/MainTimelineModernViewController.swift @@ -927,16 +927,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") } From a1c4b35a7f09e51095484fa1c4538006d3ce7dc6 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Wed, 1 Apr 2026 11:05:25 -0700 Subject: [PATCH 6/6] Fix layout issues for timeline toolbar on iOS 17/18/ --- .../MainTimelineModernViewController.swift | 76 +++++++++---------- 1 file changed, 34 insertions(+), 42 deletions(-) diff --git a/iOS/MainTimeline/MainTimelineModernViewController.swift b/iOS/MainTimeline/MainTimelineModernViewController.swift index 51db1762e..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] } @@ -951,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 {