pub enum ProviderError {
Show 17 variants
Http(Error),
Api {
code: u16,
message: String,
},
InvalidApiKey,
ModelNotFound {
model: String,
},
RateLimit,
QuotaExceeded,
ServiceUnavailable,
Timeout,
Serialization(Error),
InvalidResponse,
Configuration {
message: String,
},
ProviderNotSupported {
provider: String,
},
FeatureNotSupported {
feature: String,
},
AuthenticationFailed {
reason: String,
},
ValidationError {
field: String,
message: String,
},
NetworkError {
message: String,
},
RetryableError {
message: String,
},
}
Expand description
Provider-specific API and communication errors.
This enum represents errors that can occur during interactions with individual AI providers, including API errors, authentication failures, rate limiting, and service unavailability.
§Examples
use ultrafast_models_sdk::ProviderError;
// Handle provider-specific errors
match provider.chat_completion(request).await {
Ok(response) => println!("Success"),
Err(ProviderError::InvalidApiKey) => {
println!("Invalid API key");
}
Err(ProviderError::RateLimit) => {
println!("Rate limit exceeded");
}
Err(ProviderError::ServiceUnavailable) => {
println!("Service unavailable");
}
Err(e) => println!("Other error: {}", e),
}
Variants§
Http(Error)
HTTP client and network communication errors
Api
Provider API-specific errors with status code and message
InvalidApiKey
Invalid or missing API key errors
ModelNotFound
Requested model not found or unsupported
RateLimit
Rate limit exceeded for this provider
QuotaExceeded
Provider quota exceeded
Provider service temporarily unavailable
Timeout
Request timeout errors
Serialization(Error)
JSON serialization and deserialization errors
InvalidResponse
Invalid or malformed response format
Configuration
Invalid or missing provider configuration
ProviderNotSupported
Unsupported provider type
FeatureNotSupported
Unsupported feature for this provider
AuthenticationFailed
Authentication and authorization failures
ValidationError
Request validation failures
NetworkError
Network connectivity and communication errors
RetryableError
Retryable errors that can be attempted again
Trait Implementations§
Source§impl Debug for ProviderError
impl Debug for ProviderError
Source§impl Display for ProviderError
impl Display for ProviderError
Source§impl Error for ProviderError
impl Error for ProviderError
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
Source§impl From<Error> for ProviderError
impl From<Error> for ProviderError
Source§impl From<Error> for ProviderError
impl From<Error> for ProviderError
Source§impl From<ProviderError> for ClientError
impl From<ProviderError> for ClientError
Source§fn from(source: ProviderError) -> Self
fn from(source: ProviderError) -> Self
Auto Trait Implementations§
impl Freeze for ProviderError
impl !RefUnwindSafe for ProviderError
impl Send for ProviderError
impl Sync for ProviderError
impl Unpin for ProviderError
impl !UnwindSafe for ProviderError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string
, but without panic on OOM.