Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EncryptedStore: Fixed not throwing error in Swift #315

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions Incremental Store/EncryptedStore.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -297,14 +296,25 @@ + (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;
}

+ (NSPersistentStoreDescription *)makeDescriptionWithOptions:(NSDictionary *)options configuration:(NSString *)configuration error:(NSError * __autoreleasing*)error {
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;
Expand Down