a2a_client/
error.rs

1//! Error types for A2A client operations
2
3use thiserror::Error;
4
5/// Main error type for A2A client operations
6#[derive(Debug, Error)]
7pub enum A2AError {
8    /// Network communication error
9    #[error("Network error: {message}")]
10    NetworkError { message: String },
11
12    /// JSON serialization/deserialization error
13    #[error("Serialization error: {message}")]
14    SerializationError { message: String },
15
16    /// Remote agent returned an error
17    #[error("Remote agent error: {message}")]
18    RemoteAgentError { message: String, code: Option<i32> },
19
20    /// Invalid configuration or parameters
21    #[error("Invalid parameter: {message}")]
22    InvalidParameter { message: String },
23}
24
25/// Convenience type alias for Results with A2AError
26pub type A2AResult<T> = std::result::Result<T, A2AError>;
27
28// Conversion from reqwest::Error
29impl From<reqwest::Error> for A2AError {
30    fn from(error: reqwest::Error) -> Self {
31        A2AError::NetworkError {
32            message: error.to_string(),
33        }
34    }
35}
36
37// Conversion from serde_json::Error
38impl From<serde_json::Error> for A2AError {
39    fn from(error: serde_json::Error) -> Self {
40        A2AError::SerializationError {
41            message: error.to_string(),
42        }
43    }
44}