Enhance error handling to make syncing more resilient to network failures.

This commit is contained in:
Maurice Parker 2019-05-21 19:15:24 -05:00
parent d289bbea94
commit a406fa9d4d
2 changed files with 6 additions and 1 deletions

View File

@ -428,6 +428,7 @@ final class FeedbinAPICaller: NSObject {
completion(.success((entries, pagingInfo.nextPage, lastPageNumber))) completion(.success((entries, pagingInfo.nextPage, lastPageNumber)))
case .failure(let error): case .failure(let error):
self?.accountMetadata?.lastArticleFetch = nil
completion(.failure(error)) completion(.failure(error))
} }
@ -444,7 +445,7 @@ final class FeedbinAPICaller: NSObject {
let request = URLRequest(url: callURL, credentials: credentials) let request = URLRequest(url: callURL, credentials: credentials)
transport.send(request: request, resultType: [FeedbinEntry].self) { result in transport.send(request: request, resultType: [FeedbinEntry].self) { [weak self] result in
switch result { switch result {
case .success(let (response, entries)): case .success(let (response, entries)):
@ -453,6 +454,7 @@ final class FeedbinAPICaller: NSObject {
completion(.success((entries, pagingInfo.nextPage))) completion(.success((entries, pagingInfo.nextPage)))
case .failure(let error): case .failure(let error):
self?.accountMetadata?.lastArticleFetch = nil
completion(.failure(error)) completion(.failure(error))
} }

View File

@ -164,6 +164,7 @@ final class FeedbinAccountDelegate: AccountDelegate {
case .failure(let error): case .failure(let error):
guard let self = self else { return } guard let self = self else { return }
os_log(.info, log: self.log, "Retrieving unread entries failed: %@.", error.localizedDescription) os_log(.info, log: self.log, "Retrieving unread entries failed: %@.", error.localizedDescription)
group.leave()
} }
} }
@ -177,6 +178,7 @@ final class FeedbinAccountDelegate: AccountDelegate {
case .failure(let error): case .failure(let error):
guard let self = self else { return } guard let self = self else { return }
os_log(.info, log: self.log, "Retrieving starred entries failed: %@.", error.localizedDescription) os_log(.info, log: self.log, "Retrieving starred entries failed: %@.", error.localizedDescription)
group.leave()
} }
} }
@ -1068,6 +1070,7 @@ private extension FeedbinAccountDelegate {
case .failure(let error): case .failure(let error):
guard let self = self else { return } guard let self = self else { return }
os_log(.error, log: self.log, "Refresh articles for additional pages failed: %@.", error.localizedDescription) os_log(.error, log: self.log, "Refresh articles for additional pages failed: %@.", error.localizedDescription)
completion()
} }
} }