vtcode_acp_client/
error.rs1pub type AcpResult<T> = Result<T, AcpError>;
5
6#[derive(Debug, thiserror::Error)]
8pub enum AcpError {
9 #[error("Agent not found: {0}")]
11 AgentNotFound(String),
12
13 #[error("Network error: {0}")]
15 NetworkError(String),
16
17 #[error("Serialization error: {0}")]
19 SerializationError(String),
20
21 #[error("Invalid request: {0}")]
23 InvalidRequest(String),
24
25 #[error("Remote error from {agent_id}: {message}{code}", code = if let Some(code) = code { format!(" (code: {})", code) } else { String::new() })]
27 RemoteError {
28 agent_id: String,
29 message: String,
30 code: Option<i32>,
31 },
32
33 #[error("Timeout: {0}")]
35 Timeout(String),
36
37 #[error("Configuration error: {0}")]
39 ConfigError(String),
40
41 #[error("Internal error: {0}")]
43 Internal(String),
44}
45
46impl From<reqwest::Error> for AcpError {
47 fn from(err: reqwest::Error) -> Self {
48 AcpError::NetworkError(err.to_string())
49 }
50}
51
52impl From<serde_json::Error> for AcpError {
53 fn from(err: serde_json::Error) -> Self {
54 AcpError::SerializationError(err.to_string())
55 }
56}
57
58impl From<anyhow::Error> for AcpError {
59 fn from(err: anyhow::Error) -> Self {
60 AcpError::Internal(err.to_string())
61 }
62}