mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-11 20:00:30 +01:00
make CoreStoreError dynamicc initializer public
This commit is contained in:
@@ -78,6 +78,29 @@ public enum CoreStoreError: Error, CustomNSError, Hashable {
|
||||
Attempted to perform a fetch but could not find any related persistent store.
|
||||
*/
|
||||
case persistentStoreNotFound(entity: DynamicObject.Type)
|
||||
|
||||
/**
|
||||
Casts any `Error` to a known `CoreStoreError`, or wraps it in `CoreStoreError.internalError(NSError:)`.
|
||||
*/
|
||||
public init(_ error: Error?) {
|
||||
|
||||
guard let error = error else {
|
||||
|
||||
self = .unknown
|
||||
return
|
||||
}
|
||||
switch error {
|
||||
|
||||
case let error as CoreStoreError:
|
||||
self = error
|
||||
|
||||
case let error as NSError:
|
||||
self = .internalError(NSError: error)
|
||||
|
||||
default:
|
||||
self = .unknown
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: CustomNSError
|
||||
@@ -253,29 +276,6 @@ public enum CoreStoreError: Error, CustomNSError, Hashable {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: Internal
|
||||
|
||||
internal init(_ error: Error?) {
|
||||
|
||||
guard let error = error else {
|
||||
|
||||
self = .unknown
|
||||
return
|
||||
}
|
||||
switch error {
|
||||
|
||||
case let error as CoreStoreError:
|
||||
self = error
|
||||
|
||||
case let error as NSError:
|
||||
self = .internalError(NSError: error)
|
||||
|
||||
default:
|
||||
self = .unknown
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user