user #keyPath() for keys in demo app and in unit tests

This commit is contained in:
John Estropia
2016-09-09 17:05:55 +09:00
parent 0fa2a23461
commit e5245a0e5b
27 changed files with 1002 additions and 851 deletions

View File

@@ -32,7 +32,7 @@ import CoreData
/**
All errors thrown from CoreStore are expressed in `CoreStoreError` enum values.
*/
public enum CoreStoreError: Error, Hashable {
public enum CoreStoreError: Error, CustomNSError, Hashable {
/**
A failure occured because of an unknown error.
@@ -60,14 +60,14 @@ public enum CoreStoreError: Error, Hashable {
case internalError(NSError: NSError)
// MARK: ErrorType
// MARK: CustomNSError
public var _domain: String {
public static var errorDomain: String {
return CoreStoreErrorDomain
}
public var _code: Int {
public var errorCode: Int {
switch self {
@@ -88,6 +88,37 @@ public enum CoreStoreError: Error, Hashable {
}
}
public var errorUserInfo: [String : Any] {
switch self {
case .unknown:
return [:]
case .differentStorageExistsAtURL(let existingPersistentStoreURL):
return [
"existingPersistentStoreURL": existingPersistentStoreURL
]
case .mappingModelNotFound(let localStoreURL, let targetModel, let targetModelVersion):
return [
"localStoreURL": localStoreURL,
"targetModel": targetModel,
"targetModelVersion": targetModelVersion
]
case .progressiveMigrationRequired(let localStoreURL):
return [
"localStoreURL": localStoreURL
]
case .internalError(let NSError):
return [
"NSError": NSError
]
}
}
// MARK: Hashable