Error code
The asynchronous APIs provided by Vehicle SDK deliver results through onComplete and onFailed callbacks. In your app, if the Exception passed to onFailed is a VehicleException, use its errorCode property to identify the ErrorCode value. An exception passed to onFailed is not always a VehicleException.
- onFailed signature: Get and Set APIs, checkXXXCapabilities, and VehicleListener all use the Kotlin standard Exception. ErrorCode is not passed directly as a callback argument.
- ErrorCode definition: An enum in the ai.pleos.playground.vehicle.constant package. Vehicle SDK uses it to classify internal errors, and public APIs expose it through VehicleException.errorCode.
Use checkXXXCapabilities in advance to avoid unsupported calls. For permission errors, see Permission.
Error delivery flow
onFailed handling example
- Kotlin
- Java
door.getCurrentDoorPosition(
area = DoorArea(DoorValue.ROW_1_LEFT),
onComplete = { pos -> },
onFailed = { e ->
if (e is VehicleException) {
when (e.errorCode) {
ErrorCode.ERROR_NOT_SUPPORTED_PROPERTY,
ErrorCode.ERROR_NOT_SUPPORTED_AREA -> { /* Disable the UI */ }
ErrorCode.ERROR_SECURITY_PERMISSION -> { /* Check manifest permissions */ }
ErrorCode.ERROR_SERVICE_CONNECTION_FAILURE,
ErrorCode.ERROR_INTERNAL_SERVICE -> { /* Initialize or retry */ }
else -> Log.e("Vehicle API error: ${e.errorCode} ??${e.message}")
}
} else {
Log.e("Vehicle API error: ${e.message}")
}
}
)
door.getCurrentDoorPosition(
new DoorArea(DoorValue.ROW_1_LEFT),
pos -> Unit.INSTANCE,
e -> {
if (e instanceof VehicleException) {
ErrorCode code = ((VehicleException) e).getErrorCode();
// Handle the failure based on code
}
return Unit.INSTANCE;
}
);
ErrorCode list
| ErrorCode | Description | Recommended action |
|---|---|---|
| ERROR_NOT_SUPPORTED_PROPERTY | The property or feature is not supported | Disable the UI or use an alternate flow |
| ERROR_NOT_SUPPORTED_AREA | The area is not supported | Select a different area |
| ERROR_NOT_SUPPORTED_VALUE_TYPE | The value type is not supported | Check the parameter and type |
| ERROR_SECURITY_PERMISSION | Insufficient permission | Check Permission and @RequiresPermission |
| ERROR_SERVICE_CONNECTION_FAILURE | Failed to connect to Vehicle Service | Check initialize() and the emulator state |
| ERROR_INTERNAL_SERVICE | Internal service error | Retry or notify the user of a temporary error |
| ERROR_DRIVING_RESTRICTED | The feature is restricted while driving | Inform the user of the driving restriction |
| ERROR_EMPTY_RESULT | No result was returned | Show an empty state in the UI |
| ERROR_UNDEFINED | Undefined error | Log the error and retry |