On-demand Rides and Deliveries Solution is currently available only to select partners.

Handle Consumer SDK Errors

The Consumer SDK sends trip update errors to the consumer app using a callback mechanism. The callback parameter is a platform-specific return type ( TripUpdateError on Android, and NSError on iOS).

Extracting status codes

The errors passed to the callback are typically gRPC errors, and you can also extract additional information from them in the form of a status code. For the complete list of status codes, see Status codes and their use in gRPC.

Java

You can extract a gRPC status code that provides details about the error from the TripUpdateError returned from onTripUpdateError().

// Called when there is a trip update error.
@Override
public void onTripUpdateError(TripInfo tripInfo, TripUpdateError error)
  Status.Code code = error.getStatusCode();
}

Swift

The NSError is called back in tripModel(_:didFailUpdateTripWithError:).

// Called when there is a trip update error.
func tripModel(_ tripModel: GMTCTripModel, didFailUpdateTripWithError error: Error?) {
  // Check to see if the error comes from gRPC.
  if let error = error as NSError?, error.domain == "io.grpc" {
    let gRPCErrorCode = error.code
    ...
  }
}

Objective-C

The NSError is called back in tripModel:didFailUpdateTripWithError:.

// Called when there is a trip update error.
- (void)tripModel:(GMTCTripModel *)tripModel didFailUpdateTripWithError:(NSError *)error {
  // Check to see if the error comes from gRPC.
  if ([error.domain isEqualToString:@"io.grpc"]) {
    NSInteger gRPCErrorCode = error.code;
    ...
  }
}

Interpreting status codes

Status codes cover two kinds of errors: server and network-related errors, and client-side errors.

Server and network errors

The following status codes are for either network or server errors, and you don't need to any take action to resolve them. The Consumer SDK automatically recovers from them.

Status CodeDescription
ABORTED The server stopped sending the response. This is normally caused by a server problem.
CANCELLED The server terminated the outgoing response. This normally happens when
the app is sent to the background, or when there is a state change in the
Consumer app.
INTERRUPTED
DEADLINE_EXCEEDED The server took too long to respond.
UNAVAILABLE The server was unavailable. This is normally caused by a network problem.

Client errors

The following status codes are for client errors, and you must take action to resolve them. The Consumer SDK continues retrying to refresh the trip until you end journey sharing, but it won't recover until you take action.

Status CodeDescription
INVALID_ARGUMENT The Consumer app specified an invalid trip name; The trip name must follow the format providers/{provider_id}/trips/{trip_id}.
NOT_FOUND The trip was never created.
PERMISSION_DENIED The Consumer app has insufficient permissions. This error occurs when:
  • The Consumer app doesn't have permissions
  • The Consumer SDK isn't enabled for the project in the Google Cloud Console.
  • The JWT token is either missing or is invalid.
  • The JWT token is signed with a trip ID that doesn't match the requested trip.
RESOURCE_EXHAUSTED The resource quota is at zero, or the rate of traffic flow exceeds the speed limit.
UNAUTHENTICATED The request failed authentication due to an invalid JWT token. This error occurs either when the JWT token is signed without a trip ID, or when the JWT token has expired.