mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-11 20:00:30 +01:00
Uncaught Exception - KeyPath Not Found #296
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @damianstrain on GitHub (Dec 8, 2019).
Hi John,
I am deleting an Entity by a specified
keyusing the following code (CoreStore v6.3.2):An uncaught exception gets raised when an unknown Entity
keyis passed, specifically inNSManagedObjectContext+Querying.swift, line 568.I would have expected a
CoreStoreErrorto be thrown? so that I may handle it in myfailureclosure. Unfortunately all I get is aSIGABRTand it crashes.On a side note, I only came across this due to me mistyping the
key😃@JohnEstropia commented on GitHub (Dec 11, 2019):
@damianstrain What is
key? The recommended syntax for this is using KeyPaths as those are type-safe:@damianstrain commented on GitHub (Dec 11, 2019):
@JohnEstropia
keyin this case isuuid, and yes you are 100% correct, doingwhere(\.key ==value)is more type safe and I have since changed it to use KeyPaths.But Im still curious though, shouldn't a
CoreStoreErrorget thrown if the KeyPath is incorrect?@JohnEstropia commented on GitHub (Jan 7, 2020):
The
CoreStoreErrors are meant to be used for tracking misconfigurations in the stores or in the models. KeyPath mistakes are meant to be caught during compile time, and the type-safe syntax should be reliable enough to catch those. The type-erased dynamic utilities (likeWhere(_:isEqualTo:)) are meant for more complex uses, but leaves correctness as the caller's responsibility.