[Swift] Include HTTP status code and body data in response errors#3624
Merged
wing328 merged 3 commits intoswagger-api:masterfrom Aug 24, 2016
Merged
[Swift] Include HTTP status code and body data in response errors#3624wing328 merged 3 commits intoswagger-api:masterfrom
wing328 merged 3 commits intoswagger-api:masterfrom
Conversation
This is useful when differentiating different error responses. Example:
if let e = error {
switch e {
case ErrorResponse.Error(400, _, _): responseLabel.text = "Unknown error"
case ErrorResponse.Error(403, _, _): responseLabel.text = "Not logged in"
default: responseLabel.text = "\(e)"
}
}
The existing error is straight from Alamofire and only includes the HTTP
status code in the body of the message (not broken out as a separate value).
It also does not include the response body, which may be useful.
| expectation.fulfill() | ||
|
|
||
| switch error { | ||
| case ErrorResponse.Error(200, _, _): |
Contributor
There was a problem hiding this comment.
Will there ever be an error w/ a 200 status? This reads a little odd here.
Contributor
Author
There was a problem hiding this comment.
I agree, this is awkard. It's result of the current swift implementation, which doesn't handle Void responses currently. Let me see if I can make that go away.
Contributor
Author
8428075 to
1eb7629
Compare
1eb7629 to
e89f914
Compare
| XCTFail("error logging out") | ||
| } | ||
| PetAPI.deletePet(petId: 1000).then { | ||
| expectation.fulfill() |
Contributor
There was a problem hiding this comment.
do we still have to do some type of error checking here?
Contributor
Author
There was a problem hiding this comment.
There's no more error, and we're using the then block.
Contributor
Contributor
|
Thanks all for the work. All the Petstore tests passed locally. |
Contributor
Author
|
🎈 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is useful when differentiating different error responses. Example:
The existing error is straight from Alamofire and only includes the HTTP
status code in the body of the message (not broken out as a separate value).
It also does not include the response body, which may be useful.