Skip to content

Commit

Permalink
make CoreStoreError dynamicc initializer public
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnEstropia committed Jul 8, 2022
1 parent 1ed819b commit 6264022
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions Sources/CoreStoreError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}
}


Expand Down

0 comments on commit 6264022

Please sign in to comment.