forked from shadowfacts/Tusker
Report DraftsPersistentContainer initializer errors to Sentry
This commit is contained in:
parent
145ffbfcf0
commit
3dd0f3a154
|
@ -16,6 +16,8 @@ public class DraftsPersistentContainer: NSPersistentContainer {
|
|||
|
||||
public static let shared = DraftsPersistentContainer()
|
||||
|
||||
public static var captureError: ((any Error) -> Void)?
|
||||
|
||||
private static let managedObjectModel: NSManagedObjectModel = {
|
||||
let url = Bundle.module.url(forResource: "Drafts", withExtension: "momd")!
|
||||
return NSManagedObjectModel(contentsOf: url)!
|
||||
|
@ -39,6 +41,7 @@ public class DraftsPersistentContainer: NSPersistentContainer {
|
|||
|
||||
loadPersistentStores { _, error in
|
||||
if let error {
|
||||
DraftsPersistentContainer.captureError?(error)
|
||||
fatalError("Loading persistent store: \(error)")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,6 +56,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
|||
|
||||
// make sure the persistent container is initialized on the main thread
|
||||
// otherwise initializing it on the background thread can deadlock with accessing it on the main thread elsewhere
|
||||
#if canImport(Sentry)
|
||||
DraftsPersistentContainer.captureError = { SentrySDK.capture(error: $0) }
|
||||
#endif
|
||||
_ = DraftsPersistentContainer.shared
|
||||
|
||||
DispatchQueue.global(qos: .userInitiated).async {
|
||||
|
|
Loading…
Reference in New Issue