Skip to main content

adk_acp/
error.rs

1//! Error types for ACP integration.
2
3use thiserror::Error;
4
5/// Errors that can occur during ACP operations.
6#[derive(Debug, Error)]
7pub enum AcpError {
8    /// Failed to spawn the ACP agent process.
9    #[error("failed to spawn ACP agent: {0}")]
10    Spawn(String),
11
12    /// ACP protocol error (initialization, session, or prompt failure).
13    #[error("ACP protocol error: {0}")]
14    Protocol(String),
15
16    /// The ACP agent returned an error response.
17    #[error("ACP agent error: {0}")]
18    AgentError(String),
19
20    /// Connection to the ACP agent was lost.
21    #[error("ACP connection lost: {0}")]
22    ConnectionLost(String),
23
24    /// Timeout waiting for ACP agent response.
25    #[error("ACP agent timed out after {0}ms")]
26    Timeout(u64),
27
28    /// Invalid configuration for the ACP agent.
29    #[error("invalid ACP agent config: {0}")]
30    InvalidConfig(String),
31}
32
33impl From<AcpError> for adk_core::AdkError {
34    fn from(err: AcpError) -> Self {
35        adk_core::AdkError::tool(err.to_string())
36    }
37}
38
39/// Result type for ACP operations.
40pub type Result<T> = std::result::Result<T, AcpError>;