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

Misleading guard statement in NavigationDirections.calculate(_:) #2273

Closed
JThramer opened this issue Nov 18, 2019 · 1 comment · Fixed by #2374
Closed

Misleading guard statement in NavigationDirections.calculate(_:) #2273

JThramer opened this issue Nov 18, 2019 · 1 comment · Fixed by #2374
Assignees
Labels
bug Something isn’t working

Comments

@JThramer
Copy link
Contributor

NavigationDirectionsConstants.offlineSerialQueue.async { [weak self] in
guard let result = self?.navigator.getRouteForDirectionsUri(url.absoluteString) else {
let message = NSLocalizedString("OFFLINE_NO_RESULT", bundle: .mapboxCoreNavigation, value: "Unable to calculate the requested route while offline.", comment: "Error description when an offline route request returns no result")
let error = OfflineRoutingError.unexpectedRouteResult(message)
return completionHandler(nil, nil, error as NSError)
}

Currently we're only returning the OFFLINE_NO_RESULT error if the directions client is improperly handled (self is nil when the asynchronous closure executes.) We should have a separate error for that, and actually check the result to ensure no error was returned from nav native.

/cc @mapbox/navigation-ios

@JThramer JThramer added bug Something isn’t working user: support labels Nov 18, 2019
@JThramer JThramer added this to the v1.0.0 milestone Nov 18, 2019
@JThramer JThramer self-assigned this Nov 18, 2019
@1ec5
Copy link
Contributor

1ec5 commented Mar 3, 2020

The suggestion is to break up the guard statement so that it only checks whether self (NavigationDirections) is still around; a let further down can call getRouteForDirectionsUri(_:).

@1ec5 1ec5 changed the title Offline errors are badly written. Misleading guard statement in NavigationDirections.calculate(_:) Mar 3, 2020
@1ec5 1ec5 removed this from the v1.0.0 milestone Mar 3, 2020
@Udumft Udumft self-assigned this May 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn’t working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants