#[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
Provider(Box<ProviderError>)
A provider adapter failed.
Retry
Retries were exhausted or stopped early.
Fields
reason: RetryReasonWhy retrying stopped.
errors: Vec<ProviderError>Errors of every attempt, oldest first.
Timeout
A configured timeout elapsed.
Cancelled
The caller cancelled the operation.
InvalidArgument
A call setting is invalid.
InvalidPrompt
The prompt is invalid (empty, both prompt and messages, …).
MessageConversion
A message could not be converted to the specification prompt.
Download(Box<DownloadDetails>)
A URL in the prompt could not be downloaded.
InvalidDataContent
Inline data content (base64, data URL) is invalid.
NoSuchTool
The model called a tool that is not in the tool set.
Fields
InvalidToolInput(Box<InvalidToolInputDetails>)
The model produced input that does not match the tool schema.
ToolCallRepair
The tool call repair function failed.
Fields
ToolChoiceViolation
tool_choice required one tool but the model called another.
ToolCallNotFoundForApproval
An approval response refers to a tool call missing from the history.
Fields
tool_call_id: ToolCallIdThe referenced tool call.
approval_id: ApprovalIdThe approval concerned.
ToolChoiceNotSatisfied
The model finished without the tool call that the tool choice required.
InvalidToolApproval
An approval response is invalid (unknown request, bad signature).
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.
InvalidStreamPart
The provider stream violated the specification contract.
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
impl Error
Sourcepub fn invalid_argument(
argument: impl Into<String>,
message: impl Into<String>,
) -> Self
pub fn invalid_argument( argument: impl Into<String>, message: impl Into<String>, ) -> Self
Creates an Error::InvalidArgument.
Sourcepub fn invalid_prompt(message: impl Into<String>) -> Self
pub fn invalid_prompt(message: impl Into<String>) -> Self
Creates an Error::InvalidPrompt.
Sourcepub fn invalid_data_content(
message: impl Into<String>,
cause: Option<BoxError>,
) -> Self
pub fn invalid_data_content( message: impl Into<String>, cause: Option<BoxError>, ) -> Self
Creates an Error::InvalidDataContent.
Sourcepub fn download(
url: Url,
status_code: Option<StatusCode>,
cause: Option<BoxError>,
) -> Self
pub fn download( url: Url, status_code: Option<StatusCode>, cause: Option<BoxError>, ) -> Self
Creates an Error::Download.
Sourcepub fn no_such_tool(
tool_name: impl Into<ToolName>,
available_tools: Vec<ToolName>,
) -> Self
pub fn no_such_tool( tool_name: impl Into<ToolName>, available_tools: Vec<ToolName>, ) -> Self
Creates an Error::NoSuchTool.
Sourcepub fn invalid_tool_input(
tool_name: impl Into<ToolName>,
tool_input: impl Into<String>,
cause: impl Into<BoxError>,
) -> Self
pub fn invalid_tool_input( tool_name: impl Into<ToolName>, tool_input: impl Into<String>, cause: impl Into<BoxError>, ) -> Self
Creates an Error::InvalidToolInput.
Sourcepub fn no_object_generated(details: NoObjectGeneratedDetails) -> Self
pub fn no_object_generated(details: NoObjectGeneratedDetails) -> Self
Creates an Error::NoObjectGenerated.
Sourcepub fn no_such_provider(details: NoSuchProviderDetails) -> Self
pub fn no_such_provider(details: NoSuchProviderDetails) -> Self
Creates an Error::NoSuchProvider.
Sourcepub fn invalid_stream_part(message: impl Into<String>) -> Self
pub fn invalid_stream_part(message: impl Into<String>) -> Self
Creates an Error::InvalidStreamPart.
Sourcepub fn stream(error: StreamError) -> Self
pub fn stream(error: StreamError) -> Self
Wraps a stream error part as Error::Stream.
Sourcepub fn other(error: impl Error + Send + Sync + 'static) -> Self
pub fn other(error: impl Error + Send + Sync + 'static) -> Self
Wraps any error as Error::Other.
Sourcepub fn message(message: impl Into<String>) -> Self
pub fn message(message: impl Into<String>) -> Self
Wraps a message as Error::Other.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Returns true when retrying the operation may succeed.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Returns true when the error is the result of cancellation.
Sourcepub fn status_code(&self) -> Option<StatusCode>
pub fn status_code(&self) -> Option<StatusCode>
Returns the HTTP status of the underlying provider response, if any.
Sourcepub fn as_provider(&self) -> Option<&ProviderError>
pub fn as_provider(&self) -> Option<&ProviderError>
Returns the provider error when this error wraps one.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
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()