#[non_exhaustive]pub enum Error {
Show 15 variants
AgentInitialization(String),
AgentExecution(String),
Serialization(String),
Content(String),
Tool(String),
Service(String),
ServiceStatus {
status: u16,
message: String,
retry_after: Option<f64>,
},
ServiceInvalidAuth {
message: String,
},
ServiceInvalidRequest {
message: String,
},
ServiceContentFilter {
message: String,
},
Workflow(String),
AdditionItemMismatch(String),
Configuration(String),
Json(Error),
Other(String),
}Expand description
The primary error type for the agent framework.
This mirrors the exception hierarchy used by the Python
agent_framework.exceptions module while remaining idiomatic Rust.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
AgentInitialization(String)
An error occurred while initializing an agent.
AgentExecution(String)
An error occurred while executing an agent run.
Serialization(String)
An error occurred while (de)serializing a value.
Content(String)
A content item could not be parsed or was of an unknown type.
Tool(String)
A tool/function invocation failed.
Service(String)
A chat client / service returned an error.
Used for non-HTTP service failures (transport errors, stream-decode
errors, in-body error payloads on an otherwise-successful response). For
a non-success HTTP status, prefer Error::ServiceStatus, which also
carries the status code and any Retry-After.
ServiceStatus
A chat client / service returned a non-success HTTP status.
Distinct from Error::Service so a retry layer can inspect the
numeric status code and any server-advised Retry-After delay (in
seconds). Displays like Error::Service (a service error: ...
message), with the status code folded into the message.
This is the fallback classification for a non-success status that
isn’t one of the more specific variants below (notably 408/429/
5xx, which a retry layer treats as transient) — see
Error::ServiceInvalidAuth, Error::ServiceInvalidRequest, and
Error::ServiceContentFilter for statuses a provider client can
classify more precisely.
Fields
ServiceInvalidAuth
The service rejected the request due to missing or invalid
credentials (typically HTTP 401/403).
Mirrors upstream’s ServiceInvalidAuthError. Like Error::Service,
this carries no status code of its own (the numeric status, when
known, is folded into the message by the provider client) — it exists
so callers, and the default retry policy, can treat authentication /
authorization failures as definitively non-transient without
inspecting a status code themselves. Never retried by
RetryOn::Default.
ServiceInvalidRequest
The service rejected the request as malformed or otherwise invalid
(typically HTTP 400/404/422) for a reason other than content
filtering.
Mirrors upstream’s ServiceInvalidRequestError. See
Error::ServiceContentFilter for the content-filter-specific case.
Never retried by RetryOn::Default
— a request that was rejected as invalid will be rejected again
unchanged.
ServiceContentFilter
The service refused the request (or part of a response) because it tripped a content filter / moderation policy.
Mirrors upstream’s ServiceContentFilterException
(OpenAIContentFilterException for OpenAI/Azure OpenAI specifically).
Never retried by RetryOn::Default
— the content, not the service, is the problem.
Workflow(String)
A workflow validation or execution error.
AdditionItemMismatch(String)
Two streamed content items could not be merged (mismatched ids).
Configuration(String)
A required configuration value was missing or invalid.
Json(Error)
An underlying JSON error.
Other(String)
Any other error, wrapping a boxed source.
Implementations§
Source§impl Error
impl Error
Sourcepub fn other(msg: impl Display) -> Error
pub fn other(msg: impl Display) -> Error
Create an Error::Other from anything displayable.
Sourcepub fn service(msg: impl Display) -> Error
pub fn service(msg: impl Display) -> Error
Create an Error::Service from anything displayable.
Sourcepub fn service_status(
status: u16,
msg: impl Display,
retry_after: Option<f64>,
) -> Error
pub fn service_status( status: u16, msg: impl Display, retry_after: Option<f64>, ) -> Error
Create an Error::ServiceStatus from an HTTP status code, a message,
and an optional Retry-After delay (in seconds).
Sourcepub fn service_invalid_auth(msg: impl Display) -> Error
pub fn service_invalid_auth(msg: impl Display) -> Error
Create an Error::ServiceInvalidAuth from anything displayable.
Sourcepub fn service_invalid_request(msg: impl Display) -> Error
pub fn service_invalid_request(msg: impl Display) -> Error
Create an Error::ServiceInvalidRequest from anything displayable.
Sourcepub fn service_content_filter(msg: impl Display) -> Error
pub fn service_content_filter(msg: impl Display) -> Error
Create an Error::ServiceContentFilter from anything displayable.
Sourcepub fn status(&self) -> Option<u16>
pub fn status(&self) -> Option<u16>
The HTTP status code carried by this error, if it is an
Error::ServiceStatus.
Sourcepub fn retry_after(&self) -> Option<f64>
pub fn retry_after(&self) -> Option<f64>
The server-advised retry delay in seconds, if this is an
Error::ServiceStatus that carried a Retry-After header.
Sourcepub fn tool(msg: impl Display) -> Error
pub fn tool(msg: impl Display) -> Error
Create an Error::Tool from anything displayable.
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()