I've gotten a couple crash reports that my persistent store is failing to load in my widget. Naturally, I haven't been able to reproduce this crash and I'm pretty new to using CoreData. What is the best way to handle a persistent store failing to load?
In this article, it shows:
lazy var persistentContainer: NSPersistentContainer = {
let container = NSPersistentContainer(name: "CoreDataModelNameHere")
container.loadPersistentStores { description, error in
if let error = error {
// Add your error UI here
}
}
return container
}()
Should I show an alert or something telling the user their data couldn't be loaded and ask them to restart the app? Is there a good way of retrying? What about a widget, should I replace the widget view with an error message, or leave it in it's placeholder state?
Thanks in advance for any help!
Bonus question: What would cause the persistent store to fail loading?
Some more potentially helpful information: My store is in an app group so that I can access it from my app, the widgets, and some intents.