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

No Response Fix #314

Merged
merged 8 commits into from
Nov 21, 2018
Merged

No Response Fix #314

merged 8 commits into from
Nov 21, 2018

Conversation

JThramer
Copy link
Contributor

Is there anyone there?

Fixes #310, where a situation can arise where an API request returns an error, but that error is not matched by our blacklist and thus the SDK returns the response without an NSError, but also without a [Route] object. This should never happen.

/cc @mapbox/navigation-ios

@JThramer JThramer added the bug label Nov 20, 2018
@JThramer JThramer self-assigned this Nov 20, 2018
@@ -1,7 +1,7 @@
typealias JSONDictionary = [String: Any]

/// Indicates that an error occurred in MapboxDirections.
public let MBDirectionsErrorDomain = "MBDirectionsErrorDomain"
public let MBDirectionsErrorDomain = "com.mapbox.directions.ErrorDomain"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before anyone asks, this is a great (and rather rare) example of "Do as I say, not as I do" from Apple:

You can create your own error domains and error codes for use in your own frameworks, or even in your own applications. It is recommended that the string constant for the domain be of the form com.company.framework_or_app.ErrorDomain.

Doc Link

@akitchen
Copy link
Contributor

Thanks for turning this around. Seems like something that should really have a test case, however. Any chance you could add one?

@@ -226,7 +226,7 @@ open class Directions: NSObject {
- returns: The data task for the URL.
- postcondition: The caller must resume the returned task.
*/
fileprivate func dataTask(with url: URL, data: Data? = nil, completionHandler: @escaping (_ json: JSONDictionary) -> Void, errorHandler: @escaping (_ error: NSError) -> Void) -> URLSessionDataTask {
fileprivate func dataTask(with url: URL, data: Data? = nil, completionHandler: @escaping (_ response: HTTPURLResponse?, _ json: JSONDictionary) -> Void, errorHandler: @escaping (_ error: NSError) -> Void) -> URLSessionDataTask {

This comment was marked as resolved.

@1ec5
Copy link
Contributor

1ec5 commented Nov 21, 2018

Test Case '-[MapboxDirectionsTests.DirectionsTests testKnownBadResponse]' started.
/Users/distiller/project/MapboxDirectionsTests/DirectionsTests.swift:61: error: -[MapboxDirectionsTests.DirectionsTests testKnownBadResponse] : XCTAssertTrue failed - Wrong type of error recieved
Test Case '-[MapboxDirectionsTests.DirectionsTests testKnownBadResponse]' failed (0.009 seconds).

func testKnownBadResponse() {
let pass = "The operation couldn’t be completed. Request Entity Too Large"

OHHTTPStubs.stubRequests(passingTest: { (request) -> Bool in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testRateLimitErrorParsing() is a lot more focused, testing just Directions.informativeError(describing:response:underlyingError:) without need to stub out anything.

The recovery message should focus on the freeform parts of the request that are most likely to grow long.

Also assert that there’s no underlying error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants