Log errors that result in showing a toast to the user

This commit is contained in:
Shadowfacts 2023-04-16 14:07:30 -04:00
parent ab8ccbb408
commit 8b7c78e3b1
1 changed files with 5 additions and 0 deletions

View File

@ -9,6 +9,7 @@
import UIKit
import Pachyderm
import Sentry
import OSLog
struct ToastConfiguration {
var systemImageName: String?
@ -89,6 +90,8 @@ fileprivate extension Pachyderm.Client.Error {
}
}
private let toastErrorLogger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "ToastError")
private func captureError(_ error: Client.Error, title: String) {
let event = Event(error: error)
event.message = SentryMessage(formatted: "\(title): \(error)")
@ -123,4 +126,6 @@ private func captureError(_ error: Client.Error, title: String) {
return
}
SentrySDK.capture(event: event)
toastErrorLogger.error("\(title, privacy: .public): \(error), \(event.tags!.debugDescription, privacy: .public)")
}