Import
from vega_capability_sdk import (CancellationCapabilityError,CapabilityError,CapabilityHealthResult,CommunicationError,DependencyUnavailableError,ErrorCategory,ErrorSeverity,HardwareError,InvalidInputError,OutputValidationError,PreconditionFailedError,ProviderHealthStatus,ProviderInternalError,ResourceUnavailableError,SafetyRejectionError,TimeoutCapabilityError,UnsupportedOperationError,)
CapabilityError
class CapabilityError(Exception):def __init__(self,message: str,*,error_code: str | None = None,retryable: bool | None = None,severity: ErrorSeverity | None = None,details: Mapping[str, Any] | None = None,cause: BaseException | None = None,) -> None: ...def to_dict(self) -> dict[str, Any]: ...
Base class for expected Capability failures. details is frozen as a JSON-compatible mapping. to_dict() returns error_code, category,message, retryable, severity, and thawed details.
ErrorCategory and ErrorSeverity
ErrorCategory: invalid_input, precondition_failed,dependency_unavailable, resource_unavailable, hardware_error,communication_error, timeout, cancelled,safety_rejection, unsupported_operation,provider_internal_error, output_validation_failed.
ErrorSeverity: low, medium, high, critical.
Standard error subclasses
| Term | Meaning |
|---|---|
| InvalidInputError | invalid_input · retryable: No · medium |
| PreconditionFailedError | precondition_failed · retryable: Yes · medium |
| DependencyUnavailableError | dependency_unavailable · retryable: Yes · high |
| ResourceUnavailableError | resource_unavailable · retryable: Yes · medium |
| HardwareError | hardware_error · retryable: No · high |
| CommunicationError | communication_error · retryable: Yes · high |
| TimeoutCapabilityError | timeout · retryable: Yes · medium |
| CancellationCapabilityError | cancelled · retryable: No · medium |
| SafetyRejectionError | safety_rejection · retryable: No · critical |
| UnsupportedOperationError | unsupported_operation · retryable: No · medium |
| ProviderInternalError | provider_internal_error · retryable: No · high |
| OutputValidationError | output_validation_failed · retryable: No · medium |
Health
ProviderHealthStatus: healthy, degraded,unhealthy, unknown.
@dataclass(frozen=True, slots=True)class CapabilityHealthResult:status: ProviderHealthStatuschecked_at: datetimemessage: str | None = Nonedetails: Mapping[str, Any] | None = None
checked_at must be timezone-aware and is normalized to UTC. Class methodshealthy, degraded, unhealthy, and unknowndefault checked_at to the current UTC time.
Examples
raise DependencyUnavailableError("Speech service is unavailable",error_code="speech_backend_unavailable",details={"endpoint": "primary"},)health = CapabilityHealthResult.degraded("Backend latency is elevated",details={"latency_ms": 850},)
message or details.