diff --git a/Incremental Store/EncryptedStore.m b/Incremental Store/EncryptedStore.m index aa7a3822..4edb5e02 100755 --- a/Incremental Store/EncryptedStore.m +++ b/Incremental Store/EncryptedStore.m @@ -282,10 +282,9 @@ + (NSPersistentStoreCoordinator *)makeStoreWithOptions:(NSDictionary *)options m persistentCoordinator = [self coordinator:persistentCoordinator byAddingStoreAtURL:databaseURL configuration:nil options:options error:error]; - if (*error) - { - NSLog(@"Unable to add persistent store."); - NSLog(@"Error: %@\n%@\n%@", *error, [*error userInfo], [*error localizedDescription]); + if (*error) { + // Returning nil will cause the error object to be thrown as intended if this method is called in Swift + return nil; } return persistentCoordinator; @@ -297,7 +296,12 @@ + (NSPersistentStoreCoordinator *)coordinator:(NSPersistentStoreCoordinator *)co } [coordinator addPersistentStoreWithType:EncryptedStoreType configuration:configuration URL:url options:options error:error]; - + + if (*error) { + // Returning nil will cause the error object to be thrown as intended if this method is called in Swift + return nil; + } + return coordinator; } @@ -305,6 +309,12 @@ + (NSPersistentStoreDescription *)makeDescriptionWithOptions:(NSDictionary *)opt NSPersistentStoreDescription *description = [NSPersistentStoreDescription new]; EncryptedStoreFileManager *fileManager = [options objectForKey:self.class.optionFileManager] ?: [EncryptedStoreFileManager defaultManager]; [fileManager setupDatabaseWithOptions:options error:error]; + + if (*error) { + // Returning nil will cause the error object to be thrown as intended if this method is called in Swift + return nil; + } + description.type = self.optionType; description.URL = fileManager.databaseURL; description.configuration = configuration;