Send CoreData saving errors to Sentry

This commit is contained in:
Shadowfacts 2022-10-31 12:26:09 -04:00
parent bca7bd3586
commit 4857b507b1
1 changed files with 4 additions and 0 deletions

View File

@ -11,6 +11,7 @@ import CoreData
import Pachyderm import Pachyderm
import Combine import Combine
import OSLog import OSLog
import Sentry
fileprivate let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "PersistentStore") fileprivate let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "PersistentStore")
@ -73,6 +74,9 @@ class MastodonCachePersistentStore: NSPersistentContainer {
try context.save() try context.save()
} catch { } catch {
logger.error("Unable to save managed object context: \(String(describing: error), privacy: .public)") logger.error("Unable to save managed object context: \(String(describing: error), privacy: .public)")
let crumb = Breadcrumb(level: .fatal, category: "PersistentStore")
crumb.message = String(describing: error)
SentrySDK.addBreadcrumb(crumb: crumb)
fatalError("Unable to save managed object context") fatalError("Unable to save managed object context")
} }
} }