#[non_exhaustive]pub enum Error {
Protocol(Error),
Json(Error),
Verification(VerificationError),
Cancelled,
Disconnected,
Agent(Box<dyn Error + Send + Sync>),
}Expand description
Everything that can go wrong while hosting an AG-UI run.
The variant list is #[non_exhaustive]: new emitters and verification rules
are expected to add variants without a breaking release.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Protocol(Error)
A core protocol type rejected a value — for example an interrupt
outcome carrying no interrupts.
Json(Error)
State, tool arguments or a tool result could not be converted to or from JSON.
Verification(VerificationError)
The emitted event stream broke the protocol’s ordering rules.
Only produced when the verify feature is enabled (it is by default).
Cancelled
The run was cancelled — usually because the client disconnected.
Every emit after cancellation fails with this, so an agent that uses ?
on its emits unwinds promptly without any cancellation code of its own.
Disconnected
The consumer dropped the event stream, so there is nowhere left to emit.
Agent(Box<dyn Error + Send + Sync>)
The agent itself failed. Build one with Error::agent.
Implementations§
Source§impl Error
impl Error
Sourcepub fn agent<E>(error: E) -> Self
pub fn agent<E>(error: E) -> Self
Wraps an arbitrary agent-side error.
let err = Error::agent("the weather service is down");
assert_eq!(err.code(), "AGENT_ERROR");Sourcepub const fn code(&self) -> &'static str
pub const fn code(&self) -> &'static str
The machine-readable code placed on the RUN_ERROR event.
Sourcepub const fn is_cancelled(&self) -> bool
pub const fn is_cancelled(&self) -> bool
Whether this error means the run was cancelled rather than that it failed.
Sourcepub const fn is_disconnected(&self) -> bool
pub const fn is_disconnected(&self) -> bool
Whether the consumer has gone away, making further emits pointless.
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()