#[non_exhaustive]pub enum Error {
Validation(Box<ErrorDetails>),
AccessDenied(Box<ErrorDetails>),
ServiceQuotaExceeded(Box<ErrorDetails>),
ResourceNotFound(Box<ErrorDetails>),
Throttling(Box<ErrorDetails>),
ModelTimeout(Box<ErrorDetails>),
ModelError(Box<ErrorDetails>),
ModelStreamError(Box<ErrorDetails>),
ServiceUnavailable(Box<ErrorDetails>),
InternalServer(Box<ErrorDetails>),
MissingApiKey,
Sdk {
message: String,
retryable: bool,
},
}Expand description
The SDK error type — all variants mirror the spec §4 exception taxonomy.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Validation(Box<ErrorDetails>)
400 / invalid_request_error / VALIDATION_ERROR
AccessDenied(Box<ErrorDetails>)
401/403 / authentication_error / AUTHORIZATION_ERROR / MODEL_NOT_ALLOWED
ServiceQuotaExceeded(Box<ErrorDetails>)
402 / usage_cap_exceeded / BUDGET_EXCEEDED
ResourceNotFound(Box<ErrorDetails>)
404 / MODEL_NOT_FOUND
Throttling(Box<ErrorDetails>)
429 (retryable) / rate_limit_exceeded / RATE_LIMIT_EXCEEDED
ModelTimeout(Box<ErrorDetails>)
408 / TIMEOUT_ERROR
ModelError(Box<ErrorDetails>)
5xx model-side error
ModelStreamError(Box<ErrorDetails>)
Stream-specific error (subtype of ModelError)
503/502/504 / ServiceUnavailable
InternalServer(Box<ErrorDetails>)
500 / InternalServerException
MissingApiKey
No API key could be resolved from config or environment.
Sdk
Client-side failure. Per spec §4 only network-level failures are retryable; JSON-decode failures and malformed 200 bodies are not.
Implementations§
Source§impl Error
impl Error
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Returns true if this error is retryable per the spec retry policy.
Sourcepub fn retry_after_seconds(&self) -> Option<f64>
pub fn retry_after_seconds(&self) -> Option<f64>
Returns the Retry-After value if this error carries one.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()