Skip to main content

Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error {
Show 29 variants Provider(Box<ProviderError>), Retry { reason: RetryReason, attempts: u32, errors: Vec<ProviderError>, }, Timeout { scope: TimeoutScope, elapsed: Duration, }, Cancelled, InvalidArgument { argument: String, message: String, }, InvalidPrompt { message: String, }, MessageConversion { message: String, original_message: Box<Message>, }, Download(Box<DownloadDetails>), InvalidDataContent { message: String, cause: Option<BoxError>, }, NoSuchTool { tool_name: ToolName, available_tools: Vec<ToolName>, }, InvalidToolInput(Box<InvalidToolInputDetails>), ToolCallRepair { original: Box<Error>, cause: BoxError, }, ToolChoiceViolation { expected: ToolName, actual: ToolName, }, ToolCallNotFoundForApproval { tool_call_id: ToolCallId, approval_id: ApprovalId, }, ToolChoiceNotSatisfied { expected: Option<ToolName>, }, InvalidToolApproval { approval_id: ApprovalId, message: String, }, NoObjectGenerated(Box<NoObjectGeneratedDetails>), NoOutputGenerated, NoImageGenerated { responses: Vec<ResponseMetadata>, }, NoSpeechGenerated { responses: Vec<ResponseMetadata>, }, NoTranscriptGenerated { responses: Vec<ResponseMetadata>, }, NoTranslationGenerated { response: Box<ResponseMetadata>, }, NoVideoGenerated { responses: Vec<ResponseMetadata>, }, NoSuchProvider(Box<NoSuchProviderDetails>), NoDefaultRegistry { model_id: String, }, InvalidStreamPart { message: String, }, Stream(Box<StreamError>), Mcp(BoxError), Other(BoxError),
}
Expand description

Errors returned by the core API.

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.
§

Provider(Box<ProviderError>)

A provider adapter failed.

§

Retry

Retries were exhausted or stopped early.

Fields

§reason: RetryReason

Why retrying stopped.

§attempts: u32

Number of attempts made.

§errors: Vec<ProviderError>

Errors of every attempt, oldest first.

§

Timeout

A configured timeout elapsed.

Fields

§scope: TimeoutScope

Which timeout fired.

§elapsed: Duration

Time elapsed when it fired.

§

Cancelled

The caller cancelled the operation.

§

InvalidArgument

A call setting is invalid.

Fields

§argument: String

Name of the offending argument.

§message: String

What is wrong with it.

§

InvalidPrompt

The prompt is invalid (empty, both prompt and messages, …).

Fields

§message: String

What is wrong with it.

§

MessageConversion

A message could not be converted to the specification prompt.

Fields

§message: String

What is wrong.

§original_message: Box<Message>

The message concerned.

§

Download(Box<DownloadDetails>)

A URL in the prompt could not be downloaded.

§

InvalidDataContent

Inline data content (base64, data URL) is invalid.

Fields

§message: String

What is wrong.

§cause: Option<BoxError>

Underlying cause.

§

NoSuchTool

The model called a tool that is not in the tool set.

Fields

§tool_name: ToolName

The unknown name.

§available_tools: Vec<ToolName>

Names the model could have used.

§

InvalidToolInput(Box<InvalidToolInputDetails>)

The model produced input that does not match the tool schema.

§

ToolCallRepair

The tool call repair function failed.

Fields

§original: Box<Error>

The error the repair function was asked to fix.

§cause: BoxError

The repair function’s own error.

§

ToolChoiceViolation

tool_choice required one tool but the model called another.

Fields

§expected: ToolName

The required tool.

§actual: ToolName

The tool actually called.

§

ToolCallNotFoundForApproval

An approval response refers to a tool call missing from the history.

Fields

§tool_call_id: ToolCallId

The referenced tool call.

§approval_id: ApprovalId

The approval concerned.

§

ToolChoiceNotSatisfied

The model finished without the tool call that the tool choice required.

Fields

§expected: Option<ToolName>

The required tool, when the choice named one.

§

InvalidToolApproval

An approval response is invalid (unknown request, bad signature).

Fields

§approval_id: ApprovalId

The approval concerned.

§message: String

What is wrong.

§

NoObjectGenerated(Box<NoObjectGeneratedDetails>)

Structured output could not be parsed or validated.

§

NoOutputGenerated

The last step did not qualify for structured output parsing.

§

NoImageGenerated

Every image call returned no image.

Fields

§responses: Vec<ResponseMetadata>

Responses of the attempted calls.

§

NoSpeechGenerated

The speech model returned no audio.

Fields

§responses: Vec<ResponseMetadata>

Responses of the attempted calls.

§

NoTranscriptGenerated

The transcription model returned no text.

Fields

§responses: Vec<ResponseMetadata>

Responses of the attempted calls.

§

NoTranslationGenerated

The speech translation stream produced no translated text or audio.

Fields

§response: Box<ResponseMetadata>

Response metadata accumulated before the stream ended.

§

NoVideoGenerated

Every video call returned no video.

Fields

§responses: Vec<ResponseMetadata>

Responses of the attempted calls.

§

NoSuchProvider(Box<NoSuchProviderDetails>)

The registry has no provider with the requested id.

§

NoDefaultRegistry

A provider:model string was used without a default registry.

Fields

§model_id: String

The unresolved id.

§

InvalidStreamPart

The provider stream violated the specification contract.

Fields

§message: String

What is wrong.

§

Stream(Box<StreamError>)

The provider stream reported an error part.

§

Mcp(BoxError)

An MCP error (type-erased: the core does not depend on the MCP crate).

§

Other(BoxError)

Any other error.

Implementations§

Source§

impl Error

Source

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

Source

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

Source

pub fn invalid_data_content( message: impl Into<String>, cause: Option<BoxError>, ) -> Self

Source

pub fn download( url: Url, status_code: Option<StatusCode>, cause: Option<BoxError>, ) -> Self

Creates an Error::Download.

Source

pub fn no_such_tool( tool_name: impl Into<ToolName>, available_tools: Vec<ToolName>, ) -> Self

Creates an Error::NoSuchTool.

Source

pub fn invalid_tool_input( tool_name: impl Into<ToolName>, tool_input: impl Into<String>, cause: impl Into<BoxError>, ) -> Self

Source

pub fn no_object_generated(details: NoObjectGeneratedDetails) -> Self

Source

pub fn no_such_provider(details: NoSuchProviderDetails) -> Self

Source

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

Source

pub fn stream(error: StreamError) -> Self

Wraps a stream error part as Error::Stream.

Source

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

Wraps any error as Error::Other.

Source

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

Wraps a message as Error::Other.

Source

pub fn is_retryable(&self) -> bool

Returns true when retrying the operation may succeed.

Source

pub fn is_cancelled(&self) -> bool

Returns true when the error is the result of cancellation.

Source

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

Returns the HTTP status of the underlying provider response, if any.

Source

pub fn as_provider(&self) -> Option<&ProviderError>

Returns the provider error when this error wraps one.

Source

pub fn kind(&self) -> ErrorKind

Returns the coarse category.

Trait Implementations§

Source§

impl Debug for Error

Source§

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

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

impl Display for Error

Source§

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

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

impl Error for Error

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<&Error> for StreamErrorInfo

Source§

fn from(error: &Error) -> Self

Converts to this type from the input type.
Source§

impl From<InvalidArgumentError> for Error

Source§

fn from(error: InvalidArgumentError) -> Self

Converts to this type from the input type.
Source§

impl From<NoSuchModelError> for Error

Source§

fn from(error: NoSuchModelError) -> Self

Converts to this type from the input type.
Source§

impl From<ProviderError> for Error

Source§

fn from(error: ProviderError) -> Self

Converts to this type from the input type.
Source§

impl From<ToolError> for Error

Source§

fn from(error: ToolError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Error

§

impl !UnwindSafe for Error

§

impl Freeze for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more