1use thiserror::Error;
4
5#[derive(Debug, Error)]
7pub enum A2AError {
8 #[error("agent discovery failed: {0}")]
10 DiscoveryFailed(String),
11
12 #[error("invalid agent card: {0}")]
14 InvalidAgentCard(String),
15
16 #[error("transport error: {0}")]
18 Transport(#[from] reqwest::Error),
19
20 #[error("serialization error: {0}")]
22 Serialization(#[from] serde_json::Error),
23
24 #[error("JSON-RPC error {code}: {message}")]
26 JsonRpc {
27 code: i64,
28 message: String,
29 data: Option<serde_json::Value>,
30 },
31
32 #[error("task not found: {0}")]
34 TaskNotFound(String),
35
36 #[error("task rejected: {0}")]
38 TaskRejected(String),
39
40 #[error("task failed: {0}")]
42 TaskFailed(String),
43
44 #[error("authentication required: {0}")]
46 AuthRequired(String),
47
48 #[error("streaming error: {0}")]
50 StreamingError(String),
51
52 #[error("push notification error: {0}")]
54 PushNotificationError(String),
55
56 #[error("invalid URL: {0}")]
58 InvalidUrl(#[from] url::ParseError),
59
60 #[error("timeout after {0:?}")]
62 Timeout(std::time::Duration),
63
64 #[error("unsupported operation: {0}")]
66 Unsupported(String),
67}
68
69pub type A2AResult<T> = Result<T, A2AError>;