I have quite a few places in my iPhone application with a line like this:
if (![context save:&error]) {
/*
Replace this implementation with code to handle the error appropriately.
abort() causes the application to generate a crash log and terminate.
You should not use this function in a shipping application, although
it may be useful during development. If it is not possible to recover
from the error, display an alert panel that instructs the user to quit
the application by pressing the Home button.
*/
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
I'm sort of at a loss on what to actually replace abort() with in a production application. I don't suppose there's any simple way to allow users' devices to send the errors back to you. What's the standard practice here?
What I've done depends on what is happening in the application. If the save can be rolled back without affecting the application, you can just do that. That would be pretty rare. More likely, you are going to want to let the user know that their save failed. Depending on the cause of the failure, you can offer to try again or explain why it was invalid.
It basically depends on your application and how you would best serve the user.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With