Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

AtomicCat
Copy link

Change parseEntity to not wrap errors thrown by Decoders and Decodables 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.

…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.
Copy link
Member

@cnoon cnoon left a 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)
Copy link
Member

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).
Copy link
Member

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.
Copy link
Member

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)
Copy link
Member

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.")

Copy link
Member

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.")

Copy link
Member

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.

@cnoon cnoon self-assigned this Aug 29, 2017
@cnoon
Copy link
Member

cnoon commented Aug 29, 2017

I made all the changes suggested above and pushed them directly into master in commit e90ba0f.

@cnoon cnoon added this to the 2.2.2 milestone Aug 29, 2017
@cnoon cnoon closed this Aug 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants