mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-22 17:39:15 +01:00
Changed error-handling method to rely on new enum CoreStoreError instead of NSErrors
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// PersistentStoreResult.swift
|
||||
// SetupResult.swift
|
||||
// CoreStore
|
||||
//
|
||||
// Copyright © 2014 John Rommel Estropia
|
||||
@@ -54,7 +54,7 @@ import CoreData
|
||||
case .Success(let storage):
|
||||
// storage is the related StorageInterface instance
|
||||
case .Failure(let error):
|
||||
// error is the NSError instance for the failure
|
||||
// error is the CoreStoreError enum value for the failure
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -68,9 +68,9 @@ public enum SetupResult<T: StorageInterface>: BooleanType {
|
||||
case Success(T)
|
||||
|
||||
/**
|
||||
`SetupResult.Failure` indicates that the storage setup failed. The associated object for this value is the related `NSError` instance.
|
||||
`SetupResult.Failure` indicates that the storage setup failed. The associated object for this value is the related `CoreStoreError` enum value.
|
||||
*/
|
||||
case Failure(NSError)
|
||||
case Failure(CoreStoreError)
|
||||
|
||||
|
||||
// MARK: BooleanType
|
||||
@@ -92,19 +92,14 @@ public enum SetupResult<T: StorageInterface>: BooleanType {
|
||||
self = .Success(storage)
|
||||
}
|
||||
|
||||
internal init(_ error: NSError) {
|
||||
internal init(_ error: CoreStoreError) {
|
||||
|
||||
self = .Failure(error)
|
||||
}
|
||||
|
||||
internal init(_ errorCode: CoreStoreErrorCode) {
|
||||
internal init(_ error: ErrorType) {
|
||||
|
||||
self.init(errorCode, userInfo: nil)
|
||||
}
|
||||
|
||||
internal init(_ errorCode: CoreStoreErrorCode, userInfo: [NSObject: AnyObject]?) {
|
||||
|
||||
self.init(NSError(coreStoreErrorCode: errorCode, userInfo: userInfo))
|
||||
self = .Failure(CoreStoreError(error))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,14 +147,4 @@ public enum PersistentStoreResult: BooleanType {
|
||||
|
||||
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))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user