#[non_exhaustive]pub enum AgUiError {
Protocol(String),
Cancelled,
Json(Error),
ConnectNotImplemented,
Validation(String),
Unsupported(String),
Http {
status: u16,
url: Option<String>,
content_type: Option<String>,
body: String,
},
Transport {
message: String,
retryable: bool,
},
Other(String),
}Expand description
The unified error type for the AG-UI SDK.
The variant set is intentionally #[non_exhaustive] so new categories can be
added without a breaking change. Match with a wildcard arm when consuming it
outside of this crate.
Use AgUiError::is_retryable to decide whether an operation can be safely
retried (e.g. with backoff), and AgUiError::is_user_input to distinguish
caller mistakes from transient/transport failures.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Protocol(String)
Cancelled
Json(Error)
ConnectNotImplemented
Validation(String)
Unsupported(String)
Http
A non-success HTTP status returned by an agent endpoint.
status is the raw status code, kept transport-agnostic (the core crate
does not depend on any HTTP library). The response body and
content_type are preserved for diagnostics.
Transport
A transport-level failure (connection refused, timeout, DNS, etc.).
retryable is set by the layer that produced the error (which has access
to transport details) and is surfaced through AgUiError::is_retryable.
Other(String)
Implementations§
Source§impl AgUiError
impl AgUiError
pub fn protocol(msg: impl Into<String>) -> AgUiError
pub fn cancelled() -> AgUiError
pub fn validation(msg: impl Into<String>) -> AgUiError
pub fn unsupported(msg: impl Into<String>) -> AgUiError
pub fn other(msg: impl Into<String>) -> AgUiError
Sourcepub fn http(status: u16, body: impl Into<String>) -> AgUiError
pub fn http(status: u16, body: impl Into<String>) -> AgUiError
Builds an AgUiError::Http from a status code and response body.
Sourcepub fn transport(msg: impl Into<String>, retryable: bool) -> AgUiError
pub fn transport(msg: impl Into<String>, retryable: bool) -> AgUiError
Builds a transport error, explicitly flagging whether a retry is sensible.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Whether retrying the failed operation is likely to help.
Retryable cases:
- transport failures flagged retryable (connect/timeout/request errors)
- HTTP
5xxserver errors - HTTP
429 Too Many Requests(rate limiting / throttling)
Sourcepub fn is_user_input(&self) -> bool
pub fn is_user_input(&self) -> bool
Whether the error stems from invalid caller input rather than a transient or transport condition.
Trait Implementations§
Source§impl Error for AgUiError
impl Error for AgUiError
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()