-
Notifications
You must be signed in to change notification settings - Fork 90
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
No Response Fix #314
Conversation
…ult in edge-case where no error is omitted, but no route objects are returned.
@@ -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" |
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.
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.
Thanks for turning this around. Seems like something that should really have a test case, however. Any chance you could add one? |
MapboxDirections/MBDirections.swift
Outdated
@@ -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.
This comment was marked as resolved.
Sorry, something went wrong.
|
func testKnownBadResponse() { | ||
let pass = "The operation couldn’t be completed. Request Entity Too Large" | ||
|
||
OHHTTPStubs.stubRequests(passingTest: { (request) -> Bool in |
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.
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.
3a6919e
to
188e546
Compare
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