Changed error-handling method to rely on new enum CoreStoreError instead of NSErrors

This commit is contained in:
John Rommel Estropia
2016-03-16 07:56:19 +09:00
parent 245ec25ad8
commit d9422f7f2e
15 changed files with 296 additions and 179 deletions

View File

@@ -52,7 +52,7 @@ import Foundation
case .Success(let hasChanges):
// hasChanges indicates if there were changes or not
case .Failure(let error):
// error is the NSError instance for the failure
// error is a CoreStoreError enum value
}
}
```
@@ -65,9 +65,9 @@ public enum SaveResult {
case Success(hasChanges: Bool)
/**
`SaveResult.Failure` indicates that the `commit()` for the transaction failed. The associated object for this value is the related `NSError` instance.
`SaveResult.Failure` indicates that the `commit()` for the transaction failed. The associated object for this value is a `CoreStoreError` enum value.
*/
case Failure(NSError)
case Failure(CoreStoreError)
// MARK: Internal
@@ -77,20 +77,10 @@ public enum SaveResult {
self = .Success(hasChanges: hasChanges)
}
internal init(_ error: NSError) {
internal init(_ error: CoreStoreError) {
self = .Failure(error)
}
internal init(_ errorCode: CoreStoreErrorCode) {
self.init(errorCode, userInfo: nil)
}
internal init(_ errorCode: CoreStoreErrorCode, userInfo: [NSObject: AnyObject]?) {
self.init(NSError(coreStoreErrorCode: errorCode, userInfo: userInfo))
}
}