Skip to main content

ProviderError

Enum ProviderError 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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

Source

pub fn other(error: impl Error + Send + Sync + 'static) -> Self

Wraps an arbitrary error in ProviderError::Other.

Source

pub fn message(message: impl Into<String>) -> Self

Creates an ProviderError::Other from a message.

Source

pub fn unsupported(functionality: impl Into<String>) -> Self

Source

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.

Source

pub fn status_code(&self) -> Option<StatusCode>

Returns the HTTP status code of an API call error.

Source

pub fn as_api_call(&self) -> Option<&ApiCallError>

Returns the API call error, if this is ProviderError::ApiCall.

Source

pub fn kind_name(&self) -> &'static str

Returns a stable, low-cardinality name of the variant for telemetry.

Trait Implementations§

Source§

impl Debug for ProviderError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for ProviderError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for ProviderError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<ApiCallError> for ProviderError

Source§

fn from(error: ApiCallError) -> Self

Converts to this type from the input type.
Source§

impl From<Box<ApiCallError>> for ProviderError

Source§

fn from(error: Box<ApiCallError>) -> Self

Converts to this type from the input type.
Source§

impl From<Box<InvalidPromptError>> for ProviderError

Source§

fn from(error: Box<InvalidPromptError>) -> Self

Converts to this type from the input type.
Source§

impl From<Box<InvalidResponseDataError>> for ProviderError

Source§

fn from(error: Box<InvalidResponseDataError>) -> Self

Converts to this type from the input type.
Source§

impl From<Box<JsonParseError>> for ProviderError

Source§

fn from(error: Box<JsonParseError>) -> Self

Converts to this type from the input type.
Source§

impl From<Box<NoSuchModelError>> for ProviderError

Source§

fn from(error: Box<NoSuchModelError>) -> Self

Converts to this type from the input type.
Source§

impl From<Box<NoSuchProviderReferenceError>> for ProviderError

Source§

fn from(error: Box<NoSuchProviderReferenceError>) -> Self

Converts to this type from the input type.
Source§

impl From<Box<TooManyEmbeddingValuesForCallError>> for ProviderError

Source§

fn from(error: Box<TooManyEmbeddingValuesForCallError>) -> Self

Converts to this type from the input type.
Source§

impl From<Box<dyn Error + Sync + Send>> for ProviderError

Source§

fn from(source: BoxError) -> Self

Converts to this type from the input type.
Source§

impl From<EmptyResponseBodyError> for ProviderError

Source§

fn from(source: EmptyResponseBodyError) -> Self

Converts to this type from the input type.
Source§

impl From<InvalidArgumentError> for ProviderError

Source§

fn from(source: InvalidArgumentError) -> Self

Converts to this type from the input type.
Source§

impl From<InvalidPromptError> for ProviderError

Source§

fn from(error: InvalidPromptError) -> Self

Converts to this type from the input type.
Source§

impl From<InvalidResponseDataError> for ProviderError

Source§

fn from(error: InvalidResponseDataError) -> Self

Converts to this type from the input type.
Source§

impl From<JsonParseError> for ProviderError

Source§

fn from(error: JsonParseError) -> Self

Converts to this type from the input type.
Source§

impl From<LoadApiKeyError> for ProviderError

Source§

fn from(source: LoadApiKeyError) -> Self

Converts to this type from the input type.
Source§

impl From<LoadSettingError> for ProviderError

Source§

fn from(source: LoadSettingError) -> Self

Converts to this type from the input type.
Source§

impl From<NoContentGeneratedError> for ProviderError

Source§

fn from(source: NoContentGeneratedError) -> Self

Converts to this type from the input type.
Source§

impl From<NoSuchModelError> for ProviderError

Source§

fn from(error: NoSuchModelError) -> Self

Converts to this type from the input type.
Source§

impl From<NoSuchProviderReferenceError> for ProviderError

Source§

fn from(error: NoSuchProviderReferenceError) -> Self

Converts to this type from the input type.
Source§

impl From<TooManyEmbeddingValuesForCallError> for ProviderError

Source§

fn from(error: TooManyEmbeddingValuesForCallError) -> Self

Converts to this type from the input type.
Source§

impl From<TypeValidationError> for ProviderError

Source§

fn from(source: TypeValidationError) -> Self

Converts to this type from the input type.
Source§

impl From<UnsupportedFunctionalityError> for ProviderError

Source§

fn from(source: UnsupportedFunctionalityError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.