From dd8292fddc1117a87dc87756702c00e5cbe0e6b3 Mon Sep 17 00:00:00 2001 From: Dima Zen Date: Tue, 9 May 2017 20:35:54 +0300 Subject: [PATCH] GH-80 Add temporary core data fetch error indication --- FastEasyMapping/Source/Cache/FEMObjectCache.m | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/FastEasyMapping/Source/Cache/FEMObjectCache.m b/FastEasyMapping/Source/Cache/FEMObjectCache.m index e1cc072..0a7a7c2 100644 --- a/FastEasyMapping/Source/Cache/FEMObjectCache.m +++ b/FastEasyMapping/Source/Cache/FEMObjectCache.m @@ -84,7 +84,15 @@ - (instancetype)initWithContext:(NSManagedObjectContext *)context [fetchRequest setPredicate:predicate]; [fetchRequest setFetchLimit:primaryKeys.count]; - NSArray *existingObjects = [context executeFetchRequest:fetchRequest error:NULL]; + NSError *error = nil; + NSArray *existingObjects = [context executeFetchRequest:fetchRequest error:&error]; + + // TODO: Errors handling needed. This is a temprorary solution to at least indicate critical situation + // rather than pollute database with duplicates + if (error != nil) { + @throw [NSException exceptionWithName:NSInternalInconsistencyException reason:[error debugDescription] userInfo:nil]; + } + return existingObjects; }