#[non_exhaustive]pub enum ProviderError {
Show 16 variants
ApiCall(Box<ApiCallError>),
EmptyResponseBody(EmptyResponseBodyError),
InvalidArgument(InvalidArgumentError),
InvalidPrompt(Box<InvalidPromptError>),
InvalidResponseData(Box<InvalidResponseDataError>),
JsonParse(Box<JsonParseError>),
LoadApiKey(LoadApiKeyError),
LoadSetting(LoadSettingError),
NoContentGenerated(NoContentGeneratedError),
NoSuchModel(Box<NoSuchModelError>),
NoSuchProviderReference(Box<NoSuchProviderReferenceError>),
TooManyEmbeddingValues(Box<TooManyEmbeddingValuesForCallError>),
TypeValidation(TypeValidationError),
UnsupportedFunctionality(UnsupportedFunctionalityError),
Cancelled,
Other(BoxError),
}Expand description
Error returned by provider adapters.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
ApiCall(Box<ApiCallError>)
An HTTP call to the provider failed.
EmptyResponseBody(EmptyResponseBodyError)
The provider returned an empty body where one was required.
InvalidArgument(InvalidArgumentError)
A call argument is invalid.
InvalidPrompt(Box<InvalidPromptError>)
The prompt cannot be converted for this provider.
InvalidResponseData(Box<InvalidResponseDataError>)
The response has an unexpected shape.
JsonParse(Box<JsonParseError>)
Response text is not valid JSON.
LoadApiKey(LoadApiKeyError)
The API key could not be loaded.
LoadSetting(LoadSettingError)
A required setting could not be loaded.
NoContentGenerated(NoContentGeneratedError)
The provider produced no content.
NoSuchModel(Box<NoSuchModelError>)
The requested model does not exist.
NoSuchProviderReference(Box<NoSuchProviderReferenceError>)
A provider reference has no entry for this provider.
TooManyEmbeddingValues(Box<TooManyEmbeddingValuesForCallError>)
Too many values were passed to a single embedding call.
TypeValidation(TypeValidationError)
A value failed schema or type validation.
UnsupportedFunctionality(UnsupportedFunctionalityError)
The provider or model does not support the requested functionality.
Cancelled
The call was cancelled through its cancellation token.
Other(BoxError)
Any other error.
Implementations§
Source§impl ProviderError
impl ProviderError
Sourcepub fn other(error: impl Error + Send + Sync + 'static) -> Self
pub fn other(error: impl Error + Send + Sync + 'static) -> Self
Wraps an arbitrary error in ProviderError::Other.
Sourcepub fn message(message: impl Into<String>) -> Self
pub fn message(message: impl Into<String>) -> Self
Creates an ProviderError::Other from a message.
Sourcepub fn unsupported(functionality: impl Into<String>) -> Self
pub fn unsupported(functionality: impl Into<String>) -> Self
Creates an ProviderError::UnsupportedFunctionality error.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Returns true when retrying the call may succeed.
Only ProviderError::ApiCall carries retry information; every other
variant is not retryable.
Sourcepub fn status_code(&self) -> Option<StatusCode>
pub fn status_code(&self) -> Option<StatusCode>
Returns the HTTP status code of an API call error.
Sourcepub fn as_api_call(&self) -> Option<&ApiCallError>
pub fn as_api_call(&self) -> Option<&ApiCallError>
Returns the API call error, if this is ProviderError::ApiCall.
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
use the Display impl or to_string()