#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum A2aClientError {
#[error("HTTP {status}: {message}")]
Http { status: u16, message: String },
#[error("A2A error {status}: {message}")]
A2aError {
status: u16,
message: String,
reason: Option<String>,
},
#[error("Request error: {0}")]
Request(#[from] reqwest::Error),
#[error("JSON error: {0}")]
Json(#[from] serde_json::Error),
#[error("Type conversion error: {0}")]
Conversion(String),
#[error("SSE error: {0}")]
Sse(String),
#[error("SSE stream closed")]
StreamClosed,
}
impl A2aClientError {
pub fn reason(&self) -> Option<&str> {
match self {
Self::A2aError { reason, .. } => reason.as_deref(),
_ => None,
}
}
pub fn status(&self) -> Option<u16> {
match self {
Self::Http { status, .. } | Self::A2aError { status, .. } => Some(*status),
_ => None,
}
}
}