UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

How to handle the Persistent Error for production app

Forums > iOS

Hi

[ My Question ]

In persistent.swift (or datacontroller as Paul usually named), there are many "fatalError," couldn't be remained in shipped app. But What is the correct way to handle them?

[ What I have known/ tried ]

I found https://developer.apple.com/documentation/coredata/nsmanagedobject/1535452-validation_error_codes so I can decode the error.

I have googled and search stack overflow for several days, but I do not get any concret information. One I have seen replied that there is no point to handle in production app, because if there is not enough space, apple will have been notify the user several times, and for other error, there is nothing a developer can do to recover. Some said it is important to notify the user if it doesn't save successfully.

[ My remaining question after above efforts ]

However, I do not know what to do with those error...

For example, assuming the user fails to context.save()

Firstly, I don't know which error might occur under which command, and even I try to pick those I think most likely happened as below:

NSMigrationManagerDestinationStoreError, NSMigrationManagerSourceStoreError, NSPersistentStoreIncompleteSaveError, or NSPersistentStoreSaveError....

I don't know what I should do after knowing the error source.

Tell user there is a save error ask him to try again later? Try to save again silently?

If there is a merge error, what could i do?

If they don't find model in store, what could I do? If i create a new one, then it won't be the same as previous one.......

I see many of you have release in appconnect, It would be so nice if you like to share your experience?

Thank you very much!

4      

BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.

Get it on Hacking with Swift+

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.