davetron5000
davetron5000

Reputation: 24891

How to properly handle Core Data save errors wrt user experience on iPhone?

So, I have a basic app for storing, searching, and manipulating data. Basic CRUD operations. In various places of my code where I'm storing or updating this data, I basically have this:

NSError *error;
if (![self.managedObjectContext save:&error]) {
  // TODO: Handle this error
  NSLog(@"Error while saving data %@, %@", error, [error userInfo]);
}

What do most people do, user-experience-wise, when these sorts of things come up?

The only thing that comes to mind is to just pop up some horrible UIAlertView with a vague message that something went wrong; not really sure how to recover these things.

For the sake of argument, lets assume my model has little to no validations, so the only errors that might occur would either be something horribly wrong or a programming problem.

Any good ideas on the user experience?

Upvotes: 7

Views: 1329

Answers (3)

user113292
user113292

Reputation:

Jakob Nielsen has a few concise guidelines you might want to check out; out of everything he proposes, the one I strongly suggest you indicate in an error message that it's not the user's fault. From my own experience in user testing, most users believe they did something wrong when an error pops up, and this leads to frustration.

Maybe something like:

There was a problem saving: don't worry it's not your fault! If you restart the app, you can try again. But please contact [developer contact] and tell him the error was [short, memorable error code]

Upvotes: 5

Marcus S. Zarra
Marcus S. Zarra

Reputation: 46728

Short answer is that I have never had a save error occur in production. Normally I make these asserts and have them crash the app. This is to make sure I catch them during development.

If your application is well-written you should not have one of these occur when a user is running the application.

As for the text, it depends on your application and there is no general rule for them.

Upvotes: 0

shosti
shosti

Reputation: 7422

In a case like this, I think the best thing to do would be to present an alert to the user and quit the app.

Upvotes: 0

Related Questions