Enhance error handling to make syncing more resilient to network failures.
This commit is contained in:
parent
d289bbea94
commit
a406fa9d4d
|
@ -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))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue