Skip to content

Commit

Permalink
feat: Delete locally in case of send MailApiError
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippeWeidmann committed May 11, 2023
1 parent 02a1e4a commit 04a23ab
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions MailCore/Cache/MailboxManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1010,12 +1010,13 @@ public class MailboxManager: ObservableObject {
// Once the draft has been sent, we can delete it from Realm
try await deleteLocally(draft: draft)
return cancelableResponse
} catch {
} catch let error as AFErrorWithContext where (200 ... 299).contains(error.request.response?.statusCode ?? 0) {
// Status code is valid but something went wrong eg. we couldn't parse the response
if let statusCode = (error as? AFErrorWithContext)?.request.response?.statusCode,
(200 ... 299).contains(statusCode) {
try await deleteLocally(draft: draft)
}
try await deleteLocally(draft: draft)
throw error
} catch let error as MailApiError {
// The api returned an error
try await deleteLocally(draft: draft)
throw error
}
}
Expand Down

0 comments on commit 04a23ab

Please sign in to comment.