mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-11 20:00:30 +01:00
CoreStoreError not handling Core Data validation errors #71
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 @jannon on GitHub (Jul 21, 2016).
Hi, so I ran across some bad server data of mine that violated a validation rule on a field in one of my entities and I only get an "Unknown" error from CoreStore
The field has a max length validation rule and the data pulled from a server went over that limit. Stepping through the code in the debugger, I get to NSManagedObjectContext+transaction.swift:174
Inspecting
errorI find it is anNSErrorwithdomain= "NSCocoaErrorDomain" andcode= 1660and it has a userInfo with the following key/value pairs:
The CoreStoreError that gets initialized from that is
Unknownand so is completely useless to the calling code.I'm not sure how
self = error.flatMap { $0.bridgeToSwift } ?? .Unknownis supposed to work in theCoreStoreError.init, but it seems to be missing something.Bottom line is, it would be great if validation errors (and any other reasonable Core Data errors) were bubbled up through
CoreStoreErrorso they could be handled properly in the UI@JohnEstropia commented on GitHub (Jul 21, 2016):
Thanks for the report! This is a bug and not the intended design. Internal errors are supposed to fall back to
CoreStoreError.InternalErrorand not.Unknown.I fixed this in
2.0.2and updated the unit tests. Once the Travis CI checks complete I'll update the master branch.Once updated, internal NSErrors should all be wrapped around
CoreStoreError.InternalError. To inspect the error details just do aprint(error)and you should be given something like@jannon commented on GitHub (Jul 22, 2016):
awesome!