Skip to content

Commit

Permalink
feat: Sentry log for unknown MailError
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippeWeidmann committed May 10, 2023
1 parent 1e2829e commit 6865d75
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions MailCore/Utils/Error+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import CocoaLumberjackSwift
import Foundation
import InfomaniakCoreUI
import Sentry

public func tryOrDisplayError(_ body: () throws -> Void) {
do {
Expand All @@ -37,10 +38,18 @@ public func tryOrDisplayError(_ body: () async throws -> Void) async {
}

private func displayErrorIfNeeded(error: Error) {
if let error = error as? MailError,
error.shouldDisplay {
Task.detached {
await IKSnackBar.showSnackBar(message: error.errorDescription)
if let error = error as? MailError {
if error.shouldDisplay {
Task.detached {
await IKSnackBar.showSnackBar(message: error.errorDescription)
}
} else {
SentrySDK.capture(message: "Encountered error that we didn't display to the user") { scope in
scope.setContext(
value: ["Code": error.code, "Raw": error],
key: "Error"
)
}
}
DDLogError("MailError: \(error)")
} else if error.shouldDisplay {
Expand Down

0 comments on commit 6865d75

Please sign in to comment.