-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change parseEntity
to not wrap errors thrown by Decoders and Decodables.
#29
Conversation
…bles in a `ParserError`. This allows the decoding process to report error conditions discovered in the JSON (e.g. embedded error codes) as something other than parsing errors. Added Decoder and Decodable tests to validate that custom errors can be caught as expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few small comments here. Since you're out on PTO I'm going to make the changes so we can get this pushed through. 👍🏻
@@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. | |||
|
|||
#### 2.x Releases | |||
|
|||
* `2.2.x` Releases = [2.2.0](#220) | [2.2.1](#221) | |||
* `2.2.x` Releases = [2.2.0](#220) | [2.2.1](#221) | [2.2.2](#222) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's revert this since there's going to be another PR going into 2.2.2
.
## [2.2.2](https://github.com/Nike-Inc/Elevate/releases/tag/2.2.2) | ||
|
||
Released on 2017-06-22. All issues associated with this milestone can be found using this | ||
[filter](https://github.com/Nike-Inc/Elevate/milestone/5?closed=1). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's switch this over to master
and add a commit message for these changes.
@@ -43,12 +43,15 @@ public class Parser { | |||
/// - closure: Defines the property list for the parser via the passed in `Schema` instance. | |||
/// | |||
/// - Returns: The parsed entity as a Dictionary. | |||
/// | |||
/// - Throws: `ParserError` for parsing related errors or `Error`s thrown by custom `Decodable` and `Decoder` implementations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can condense this wording a bit.
@@ -60,6 +63,8 @@ public class Parser { | |||
} | |||
} | |||
|
|||
result = try parseEntity(json: json, closure: closure) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can just get rid of the do-catch here.
XCTAssertEqual(error.code, 42, "Error code did not match expected value.") | ||
} catch { | ||
XCTFail("Parser error was of incorrect type.") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should switch over to using the XCTAssertThrowsError
APIs here.
XCTAssertEqual(error.code, 42, "Error code did not match expected value.") | ||
} catch { | ||
XCTFail("Parser error was of incorrect type.") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should switch over to using the XCTAssertThrowsError
APIs here.
I made all the changes suggested above and pushed them directly into |
Change
parseEntity
to not wrap errors thrown by Decoders and Decodables in aParserError
.This allows the decoding process to report error conditions discovered in the JSON (e.g. embedded error codes) as something other than parsing errors.
Added Decoder and Decodable tests to validate that custom errors can be caught as expected.