My question is similar to this one, but I need further clarification. I often get exceptions during code like this:
NSError* error;
if (![managedObjectContext save:&error]) {
NSLog(@"Failed to save to data store: %@", [error localizedDescription]);
}
However, when I put a breakpoint in objc_exception_throw
, I can find out that an exception is thrown in save
:
(gdb) po [$eax name]
NSInternalInconsistencyException
(gdb) po [$eax description]
optimistic locking failure
I wouldn't expect this, since the docs say that an optimistic locking failure will return an error, not an exception.
As an aside, I can't even seem to catch this exception with @try ... @catch (NSException * e)
in the code. It's all strange.