refactor logging functions

This commit is contained in:
John Rommel Estropia
2015-02-28 11:32:41 +09:00
parent 59cd505dc6
commit 55dee6ec2f
11 changed files with 151 additions and 118 deletions

View File

@@ -59,25 +59,25 @@ internal extension NSManagedObject {
let objectID = self.objectID
if objectID.temporaryID {
var permanentIDError: NSError?
if !context.obtainPermanentIDsForObjects([self], error: &permanentIDError) {
var error: NSError?
if !context.obtainPermanentIDsForObjects([self], error: &error) {
HardcoreData.handleError(
permanentIDError!,
error ?? NSError(hardcoreDataErrorCode: .UnknownError),
"Failed to obtain permanent ID for object.")
return nil
}
}
var existingObjectError: NSError?
if let existingObject = context.existingObjectWithID(objectID, error: &existingObjectError) {
var error: NSError?
if let existingObject = context.existingObjectWithID(objectID, error: &error) {
return (existingObject as! T)
}
HardcoreData.handleError(
existingObjectError!,
"Failed to load existing NSManagedObject in context.")
error ?? NSError(hardcoreDataErrorCode: .UnknownError),
"Failed to load existing \(T.self) in context.")
return nil;
}
}