Skip to main content

AgUiError

Enum AgUiError 

Source
#[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
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.
§

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.

Fields

§status: u16
§content_type: Option<String>
§body: String
§

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.

Fields

§message: String
§retryable: bool
§

Other(String)

Implementations§

Source§

impl AgUiError

Source

pub fn protocol(msg: impl Into<String>) -> AgUiError

Source

pub fn cancelled() -> AgUiError

Source

pub fn validation(msg: impl Into<String>) -> AgUiError

Source

pub fn unsupported(msg: impl Into<String>) -> AgUiError

Source

pub fn other(msg: impl Into<String>) -> AgUiError

Source

pub fn http(status: u16, body: impl Into<String>) -> AgUiError

Builds an AgUiError::Http from a status code and response body.

Source

pub fn transport(msg: impl Into<String>, retryable: bool) -> AgUiError

Builds a transport error, explicitly flagging whether a retry is sensible.

Source

pub fn status(&self) -> Option<u16>

The HTTP status code, if this error carries one.

Source

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 5xx server errors
  • HTTP 429 Too Many Requests (rate limiting / throttling)
Source

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 Debug for AgUiError

Source§

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

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

impl Display for AgUiError

Source§

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

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

impl Error for AgUiError

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 AgUiError

Source§

fn from(source: Error) -> AgUiError

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> 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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,