title: Error handling in Core Data
body: <p>A few weeks ago I started using Core Data for the first time in a non-trivial application. One of the things that surprised and confused me was how error handling works. To give an example, one of the first things I tried was setting my data file as "locked" in Finder, to order to make sure I was properly handling the NSError object returned by reference when I set the file URL. To my surprise, instead of returning nil and setting the NSError, the persistent store coordinator raised an uncaught exception from the underlying NSData!</p>
  
  <p>At the same time, it seems like error handling is a bit unnecessary sometimes in Core Data. For instance, I don't see any obvious reason why a fetch request would need error handling beyond programmer mistakes (which, incidentally, also raise an exception in my experience). In these cases, I've been passing NULL for the NSError reference pointer.</p>
  
  <p>Between try / catch blocks and NSError I could spend a lot of time writing code to appease Core Data, but I want to be practical about it so I'm not spending time on error code that will never run. With that in mind, how do you approach error handling in your applications? What errors have you seen in the real world that you should make sure to account for?</p>