@@ -11,16 +11,18 @@ import Foundation
1111
1212/// An error that models all the possible error conditions of CoreDataRepository.
1313///
14- /// CoreDataError also conforms to CustomNSError so that it cleanly casts to NSError
14+ /// `` CoreDataError`` also conforms to ` CustomNSError` so that it cleanly casts to ` NSError`
1515public enum CoreDataError : Error , Hashable , Sendable {
1616 /// UnmanagedModels store the ``CoreData.NSManagedObjectID`` of their respective RepositoryManagedModels as a URL.
1717 /// This URL
1818 /// must be mapped back into a ``NSManagedObjectID`` for most transactions. If it fails, this error is returned.
1919 case failedToGetObjectIdFromUrl( URL )
2020
21- /// For some aggregate functions, a NSAttributeDescription is required so that a NSFetchRequest can be constructed
21+ /// For some aggregate functions, a `NSAttributeDescription` is required so that a `NSFetchRequest` can be
22+ /// constructed
2223 /// against the correct property.
23- /// If the NSAttributeDescription is not for the correct or expected NSEntityDescription, this error is returned.
24+ /// If the `NSAttributeDescription` is not for the correct or expected `NSEntityDescription`, this error is
25+ /// returned.
2426 case propertyDoesNotMatchEntity
2527
2628 /// CoreData may return a value of a related type to what is actually needed. If casting the value CoreData returns
@@ -31,23 +33,31 @@ public enum CoreDataError: Error, Hashable, Sendable {
3133 /// is returned.
3234 case fetchedObjectIsFlaggedAsDeleted
3335
34- /// If CoreData throws a CocoaError, it is embedded here.
36+ /// If CoreData throws a ` CocoaError` , it is embedded here.
3537 case cocoa( CocoaError )
3638
37- /// If the type of an error is unknown, it is cast to NSError and embedded here.
39+ /// If the type of an error is unknown, it is cast to ` NSError` and embedded here.
3840 case unknown( NSError )
3941
40- /// If a NSEntityDescription is malformed by not having a name, this error is returned.
42+ /// If a ` NSEntityDescription` is malformed by not having a name, this error is returned.
4143 case noEntityNameFound
4244
43- /// The count aggregate function requires at least one NSAttributeDescription on the NSEntityDescription. If there
45+ /// The count aggregate function requires at least one `NSAttributeDescription` on the `NSEntityDescription`. If
46+ /// there
4447 /// is none, this error is returned.
4548 case atLeastOneAttributeDescRequired
4649
47- /// If an UnmanagedModel is used in a transaction where it is expected to already be persisted but has no URL
50+ /// If a ``ManagedIdUrlReferencable`` value is used in a transaction where it is expected to already be persisted
51+ /// but has no `URL`
4852 /// representing the ``NSManagedObjectID``, this error is returned.
4953 case noUrlOnItemToMapToObjectId
5054
55+ /// If a ``ManagedIdReferencable`` value is used in a transaction where it is expected to already be persisted but
56+ /// has no `NSManagedObjectID`, this error is returned.
57+ case noObjectIdOnItem
58+
59+ case noMatchFoundWhenReadingItem
60+
5161 public var localizedDescription : String {
5262 switch self {
5363 case . failedToGetObjectIdFromUrl:
@@ -96,10 +106,23 @@ public enum CoreDataError: Error, Hashable, Sendable {
96106 )
97107 case . noUrlOnItemToMapToObjectId:
98108 return NSLocalizedString (
99- " No object ID URL found on the unmanaged model for an operation against an existing managed object. " ,
109+ " No object ID URL found on the model for an operation against an existing managed object. " ,
110+ bundle: . module,
111+ comment: " Error for performing an operation against an existing NSManagedObject but the "
112+ + " ManagedIdUrlReferencable instance has no managedIdUrl for looking up the NSManagedOjbectID. "
113+ )
114+ case . noObjectIdOnItem:
115+ return NSLocalizedString (
116+ " No object ID found on the model for an operation against an existing managed object. " ,
100117 bundle: . module,
101- comment: " Error for performing an operation against an existing NSManagedObject but the UnmanagedModel "
102- + " instance has no ManagedRepoUrl for looking up the NSManagedOjbectID. "
118+ comment: " Error for performing an operation against an existing NSManagedObject but the "
119+ + " ManagedIdReferencable instance has no managedId. "
120+ )
121+ case . noMatchFoundWhenReadingItem:
122+ return NSLocalizedString (
123+ " No match found when attempting to read an instance from CoreData. " ,
124+ bundle: . module,
125+ comment: " Error for reading an instance from CoreData but no instance was found. "
103126 )
104127 }
105128 }
@@ -129,6 +152,10 @@ extension CoreDataError: CustomNSError {
129152 return 8
130153 case . noUrlOnItemToMapToObjectId:
131154 return 9
155+ case . noObjectIdOnItem:
156+ return 10
157+ case . noMatchFoundWhenReadingItem:
158+ return 11
132159 }
133160 }
134161
@@ -155,6 +182,10 @@ extension CoreDataError: CustomNSError {
155182 return [ : ]
156183 case . noUrlOnItemToMapToObjectId:
157184 return [ : ]
185+ case . noObjectIdOnItem:
186+ return [ : ]
187+ case . noMatchFoundWhenReadingItem:
188+ return [ : ]
158189 }
159190 }
160191}
0 commit comments