Throws URLError.fileDoesNotExist for 404 responses

This commit is contained in:
Riley Testut
2022-04-14 18:29:34 -07:00
parent 643d7bf6fa
commit 751d9419ff
2 changed files with 16 additions and 0 deletions

View File

@@ -41,6 +41,14 @@ class FetchTrustedSourcesOperation: ResultOperation<[FetchTrustedSourcesOperatio
let dataTask = URLSession.shared.dataTask(with: .trustedSources) { (data, response, error) in
do
{
if let response = response as? HTTPURLResponse
{
guard response.statusCode != 404 else {
self.finish(.failure(URLError(.fileDoesNotExist, userInfo: [NSURLErrorKey: URL.trustedSources])))
return
}
}
guard let data = data else { throw error! }
let response = try Foundation.JSONDecoder().decode(Response.self, from: data)

View File

@@ -46,6 +46,14 @@ class UpdatePatronsOperation: ResultOperation<Void>
let dataTask = URLSession.shared.dataTask(with: .patreonInfo) { (data, response, error) in
do
{
if let response = response as? HTTPURLResponse
{
guard response.statusCode != 404 else {
self.finish(.failure(URLError(.fileDoesNotExist, userInfo: [NSURLErrorKey: URL.patreonInfo])))
return
}
}
guard let data = data else { throw error! }
let response = try AltStoreCore.JSONDecoder().decode(Response.self, from: data)