Error code
Async Vehicle APIs deliver results through onComplete and onFailed callbacks.
In your app, when the Exception received in onFailed is a VehicleException, check the ErrorCode value via errorCode. Not every onFailed callback will receive a VehicleException.
onFailedsignature: Get/Set APIs,checkXXXCapabilities, andVehicleListenerall use Kotlin’s standardException.ErrorCodeis not passed directly as a callback argument.ErrorCodedefinition: enum in theai.pleos.playground.vehicle.constantpackage. Used inside the Vehicle SDK for error classification; exposed in the public API viaVehicleException.errorCode.
Use checkXXXCapabilities upfront to reduce unsupported calls, and see Permission for permission errors.
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 UI */ }
ErrorCode.ERROR_SECURITY_PERMISSION -> { /* check manifest permissions */ }
ErrorCode.ERROR_SERVICE_CONNECTION_FAILURE,
ErrorCode.ERROR_INTERNAL_SERVICE -> { /* initialize·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();
// branch on code
}
return Unit.INSTANCE;
}
);
ErrorCode reference
| ErrorCode | Description | Recommended handling |
|---|---|---|
ERROR_NOT_SUPPORTED_PROPERTY | Property (feature) not supported | Disable UI or alternate flow |
ERROR_NOT_SUPPORTED_AREA | Area not supported | Change area selection |
ERROR_NOT_SUPPORTED_VALUE_TYPE | Unsupported value type | Re-check parameters and types |
ERROR_SECURITY_PERMISSION | Missing permission | Permission·@RequiresPermission |
ERROR_SERVICE_CONNECTION_FAILURE | Vehicle service connection failed | initialize()·emulator state |
ERROR_INTERNAL_SERVICE | Internal service error | Retry·temporary error message |
ERROR_DRIVING_RESTRICTED | Restricted while driving | Driving restriction notice |
ERROR_EMPTY_RESULT | Empty result | Empty-state UI |
ERROR_UNDEFINED | Undefined error | Log·retry |