I have run into a disturbing/baffling bug. Core Data seemed to be swallowing its own exception! When using the (super-useful) CoreDataHelper, I had written a badly formed fetch that resulted in a "Unimplemented SQL generation for predicate" exception. That part's simple, what's really weird is that this exception was being caught somewhere and swallowed, meaning that my code just skipped the rest of the method after that fetch and returned to the main loop without any console messages. Quite infuriating.
Eventually I was able to wrap the actual fetch request in a @try statement and @catch the exception:
@try{
fetchResults = [managedObjectContext executeFetchRequest:request error:&error];
NSLog(@"fetch successful");
}
@catch (NSException* exception) {
NSLog(@"caught exception!\n\n%@\n\n%@\n\n%@",[exception name], [exception reason], [exception userInfo]);
}
This let me figure out what it was, but it still makes no sense that it would be getting caught somewhere. I have not used @try/@catch anywhere else in my code other than to test this.
I also tried creating a blank Core Data project and using CoreDataHelper without the @try/@catch statement to try and isolate the problem, with nothing else in the project, CoreDataHelper works as it should, returning:
CoreDataTest[1044:11603] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unimplemented SQL generation for predicate ("test" LIKE attribute)'
So something in my project is catching and ignoring this exception, but it's not me unless I can somehow do that without using @catch.
What could it be?!