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 error I find it is an NSError with domain = "NSCocoaErrorDomain" and code = 1660
and it has a userInfo with the following key/value pairs:
"NSValidationErrorObject": <The object I attempted to save>
"NSValidationErrorKey": "summary",
"NSLocalizedDescription": "summary is too long",
"NSValidationErrorValue": "<The contents of the summary that are too long>"
The CoreStoreError that gets initialized from that is Unknown and so is completely useless to the calling code.
I'm not sure how self = error.flatMap { $0.bridgeToSwift } ?? .Unknown is supposed to work in the CoreStoreError.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 CoreStoreError so they could be handled properly in the UI
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](https://github.com/JohnEstropia/CoreStore/blob/develop/Sources/Internal/NSManagedObjectContext%2BTransaction.swift#L174)
Inspecting `error` I find it is an `NSError` with `domain` = "NSCocoaErrorDomain" and `code` = 1660
and it has a userInfo with the following key/value pairs:
- "NSValidationErrorObject": <The object I attempted to save>
- "NSValidationErrorKey": "summary",
- "NSLocalizedDescription": "summary is too long",
- "NSValidationErrorValue": "<The contents of the summary that are too long>"
The CoreStoreError that gets initialized from that is `Unknown` and so is completely useless to the calling code.
I'm not sure how `self = error.flatMap { $0.bridgeToSwift } ?? .Unknown` is supposed to work in the `CoreStoreError.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 `CoreStoreError` so they could be handled properly in the UI
Thanks for the report! This is a bug and not the intended design. Internal errors are supposed to fall back to CoreStoreError.InternalError and not .Unknown.
I fixed this in 2.0.2 and 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 a print(error) and you should be given something like
@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.InternalError` and not `.Unknown`.
I fixed this in `2.0.2` and 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 a `print(error)` and you should be given something like
```
(CoreStore.CoreStoreError) .InternalError (
._domain = "com.corestore.error";
._code = 4;
.NSError = (
.domain = "com.dummy";
.code = 123;
.userInfo = 3 key-value(s) [
key3 = 2016-07-21 02:38:55 +0000;
key1 = value1;
key2 = 2;
];
);
)
```
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
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!