mirror of
https://github.com/writeas/writefreely-swiftui-multiplatform.git
synced 2024-11-15 01:11:02 +00:00
Set current error on API call failures
This commit is contained in:
parent
a3b805a319
commit
faa557c2b4
@ -38,7 +38,7 @@ extension WriteFreelyModel {
|
|||||||
try purgeTokenFromKeychain(username: account.username, server: account.server)
|
try purgeTokenFromKeychain(username: account.username, server: account.server)
|
||||||
account.logout()
|
account.logout()
|
||||||
} catch {
|
} catch {
|
||||||
fatalError("Failed to log out persisted state")
|
self.currentError = KeychainError.couldNotPurgeAccessToken
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -50,7 +50,10 @@ extension WriteFreelyModel {
|
|||||||
self.currentError = NetworkError.noConnectionError
|
self.currentError = NetworkError.noConnectionError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
guard let loggedInClient = client else { return }
|
guard let loggedInClient = client else {
|
||||||
|
self.currentError = AppError.couldNotGetLoggedInClient
|
||||||
|
return
|
||||||
|
}
|
||||||
// We're starting the network request.
|
// We're starting the network request.
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self.isProcessingRequest = true
|
self.isProcessingRequest = true
|
||||||
@ -63,7 +66,10 @@ extension WriteFreelyModel {
|
|||||||
self.currentError = NetworkError.noConnectionError
|
self.currentError = NetworkError.noConnectionError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
guard let loggedInClient = client else { return }
|
guard let loggedInClient = client else {
|
||||||
|
self.currentError = AppError.couldNotGetLoggedInClient
|
||||||
|
return
|
||||||
|
}
|
||||||
// We're starting the network request.
|
// We're starting the network request.
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self.isProcessingRequest = true
|
self.isProcessingRequest = true
|
||||||
@ -78,7 +84,10 @@ extension WriteFreelyModel {
|
|||||||
self.currentError = NetworkError.noConnectionError
|
self.currentError = NetworkError.noConnectionError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
guard let loggedInClient = client else { return }
|
guard let loggedInClient = client else {
|
||||||
|
self.currentError = AppError.couldNotGetLoggedInClient
|
||||||
|
return
|
||||||
|
}
|
||||||
// We're starting the network request.
|
// We're starting the network request.
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self.isProcessingRequest = true
|
self.isProcessingRequest = true
|
||||||
@ -123,8 +132,14 @@ extension WriteFreelyModel {
|
|||||||
self.currentError = NetworkError.noConnectionError
|
self.currentError = NetworkError.noConnectionError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
guard let loggedInClient = client else { return }
|
guard let loggedInClient = client else {
|
||||||
guard let postId = post.postId else { return }
|
self.currentError = AppError.couldNotGetLoggedInClient
|
||||||
|
return
|
||||||
|
}
|
||||||
|
guard let postId = post.postId else {
|
||||||
|
self.currentError = AppError.couldNotGetPostId
|
||||||
|
return
|
||||||
|
}
|
||||||
// We're starting the network request.
|
// We're starting the network request.
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self.selectedPost = post
|
self.selectedPost = post
|
||||||
@ -138,8 +153,14 @@ extension WriteFreelyModel {
|
|||||||
self.currentError = NetworkError.noConnectionError
|
self.currentError = NetworkError.noConnectionError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
guard let loggedInClient = client,
|
guard let loggedInClient = client else {
|
||||||
let postId = post.postId else { return }
|
self.currentError = AppError.couldNotGetLoggedInClient
|
||||||
|
return
|
||||||
|
}
|
||||||
|
guard let postId = post.postId else {
|
||||||
|
self.currentError = AppError.couldNotGetPostId
|
||||||
|
return
|
||||||
|
}
|
||||||
// We're starting the network request.
|
// We're starting the network request.
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self.isProcessingRequest = true
|
self.isProcessingRequest = true
|
||||||
|
Loading…
Reference in New Issue
Block a user