Skip to content
This repository was archived by the owner on Dec 19, 2019. It is now read-only.

Commit 780a49c

Browse files
author
Luke Stringer
committed
Use NSAssert to check MOC saves without errors in operations.
When the context does not successfully save from within an operation then the error is made available from the error property. However recovering from an error once the operation has finished is next to impossible as you do not have access to the context that failed. Therefore is it better to just hard crash and fix the bug when you know the save failed.
1 parent b966370 commit 780a49c

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

Classes/shared/SQKCoreDataOperation/SQKCoreDataOperation.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ - (void)completeOperationBySavingContext:(NSManagedObjectContext *)managedObject
101101

102102
NSError *error = nil;
103103
[managedObjectContext save:&error];
104+
105+
NSAssert(error == nil, @"Save errored");
106+
104107
[self addError:error];
105108
}
106109
}

0 commit comments

Comments
 (0)