mapbox-navigation-android icon indicating copy to clipboard operation
mapbox-navigation-android copied to clipboard

Provide `onRoutesRequestFailure` reason information

Open Guardiola31337 opened this issue 4 years ago • 4 comments

Currently, we're reporting back a Throwable with a tweaked message as a result of https://github.com/mapbox/mapbox-navigation-android/blob/306f2919494f7731a0b3515a9d3d9cae5bd0ad07/libnavigation-core/src/main/java/com/mapbox/navigation/core/MapboxNavigation.kt#L386-L389 https://github.com/mapbox/mapbox-navigation-android/blob/306f2919494f7731a0b3515a9d3d9cae5bd0ad07/libnavigation-core/src/main/java/com/mapbox/navigation/core/directions/session/RoutesRequestCallback.kt#L34

Clients can parse the string Throwable.message or print the whole thing but there isn't an easy way to tell the user the reason e.g. if it was offline or service error:

if ( /* is offline error */ ) 
   // display prompt telling user to check network connection
else
   // display user message apologizing for service being down

This can't be easily implemented with given information from the Throwable.

This ticket tracks the feature request of adding some kind of Error object including the Reason so that developers can use this extra information to act accordingly to their use cases (e.g. to determine what messaging to display).

Reasons may include offline vs service error, authentication failure, bad request, etc.

cc @mapbox/navigation-android

Guardiola31337 avatar May 10 '21 21:05 Guardiola31337

Capturing more feedback on the topic.

Also depending on how the service handles it, other possible error reasons could be:

  • if maximum route length (if there is one?) for a walking or driving route is exceeded
  • if the start and end points of the route are the same (with no waypoints in-between) basically any problems with the route that we should message the client about

Guardiola31337 avatar May 10 '21 21:05 Guardiola31337

cc @mapbox/navigation-ios

Guardiola31337 avatar May 12 '21 13:05 Guardiola31337

In Swift, this code associates Directions API error codes with enumeration values that are included in the callback for route requests.

1ec5 avatar May 14 '21 16:05 1ec5

Re-opening here https://github.com/mapbox/mapbox-navigation-android/pull/4577#issue-684553741

The next steps are to expose the Directions API error codes as string defs or enums to fully close https://github.com/mapbox/mapbox-navigation-android/issues/4376, and make the similar refresh interfaces internal and hidden since they are not used outside of the SDK scope.

Guardiola31337 avatar Jul 13 '21 22:07 Guardiola31337