mapbox / mapbox-navigation-android

Mapbox Navigation SDK for Android
https://docs.mapbox.com/android/navigation/overview/
Other
622 stars 319 forks source link

Provide `onRoutesRequestFailure` reason information #4376

Open Guardiola31337 opened 3 years ago

Guardiola31337 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

cc @mapbox/navigation-ios

1ec5 commented 3 years ago

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

Guardiola31337 commented 3 years ago

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.