#[non_exhaustive]pub enum ClientError {
Http(Error),
HttpClient(String),
Serialization(Error),
Protocol(A2aError),
Transport(String),
InvalidEndpoint(String),
UnexpectedStatus {
status: u16,
body: String,
retry_after: Option<Duration>,
},
AuthRequired {
task_id: TaskId,
},
Timeout(String),
ProtocolBindingMismatch(String),
}Expand description
Errors that can occur during A2A client operations.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Http(Error)
A transport-level HTTP error from hyper.
HttpClient(String)
An HTTP-level error from the hyper-util client (connection, redirect, etc.).
Serialization(Error)
JSON serialization or deserialization error.
Protocol(A2aError)
A protocol-level A2A error returned by the server.
Transport(String)
A transport configuration or connection error.
InvalidEndpoint(String)
The agent endpoint URL is invalid or could not be resolved.
UnexpectedStatus
The server returned an unexpected HTTP status code.
Fields
AuthRequired
The agent requires authentication for this task.
Timeout(String)
A request or stream connection timed out.
ProtocolBindingMismatch(String)
The server appears to use a different protocol binding than the client.
For example, a JSON-RPC client connected to a REST-only server (or
vice-versa). Check the agent card’s supported_interfaces to select
the correct protocol binding.
Implementations§
Source§impl ClientError
impl ClientError
Sourcepub const fn retry_after(&self) -> Option<Duration>
pub const fn retry_after(&self) -> Option<Duration>
Server-requested retry delay, if this error carries one (a Retry-After
header on a 429/503). The retry layer prefers this over its computed
backoff.
Sourcepub fn is_stream_lagged(&self) -> bool
pub fn is_stream_lagged(&self) -> bool
Returns true when this is the server’s recoverable consumer-lag
signal on a streaming subscription rather than a real failure.
Do not stop reading when this is true. The stream continues, and a consumer that keeps polling still receives every later event including the terminal status. Treating it as fatal silently truncates the task:
while let Some(event) = stream.next().await {
match event {
Ok(ev) => { /* handle */ }
// Recoverable: note the gap and keep going.
Err(e) if e.is_stream_lagged() => {
eprintln!("dropped {:?} events", e.dropped_event_count());
}
Err(e) => break, // genuinely fatal
}
}Sourcepub fn dropped_event_count(&self) -> Option<u64>
pub fn dropped_event_count(&self) -> Option<u64>
Number of events the server dropped, when this is a consumer-lag
signal (see ClientError::is_stream_lagged); None otherwise.
Source§impl ClientError
impl ClientError
Sourcepub const fn is_retryable(&self) -> bool
pub const fn is_retryable(&self) -> bool
Returns true if this error is transient and the request should be retried.
Retryable errors include:
- HTTP connection/transport errors
- Timeouts
- Server errors (HTTP 502, 503, 504, 429)
Trait Implementations§
Source§impl Debug for ClientError
impl Debug for ClientError
Source§impl Display for ClientError
impl Display for ClientError
Source§impl Error for ClientError
impl Error for ClientError
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()
Source§impl From<A2aError> for ClientError
impl From<A2aError> for ClientError
Source§impl From<Error> for ClientError
impl From<Error> for ClientError
Auto Trait Implementations§
impl !RefUnwindSafe for ClientError
impl !UnwindSafe for ClientError
impl Freeze for ClientError
impl Send for ClientError
impl Sync for ClientError
impl Unpin for ClientError
impl UnsafeUnpin for ClientError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request