chasm_cli/agency/
error.rs1#![allow(dead_code)]
6
7use thiserror::Error;
8
9#[derive(Error, Debug)]
11pub enum AgencyError {
12 #[error("Agent not found: {0}")]
13 AgentNotFound(String),
14
15 #[error("Tool not found: {0}")]
16 ToolNotFound(String),
17
18 #[error("Session not found: {0}")]
19 SessionNotFound(String),
20
21 #[error("Execution failed: {0}")]
22 ExecutionFailed(String),
23
24 #[error("Tool execution failed: {tool} - {message}")]
25 ToolExecutionFailed { tool: String, message: String },
26
27 #[error("Model error: {0}")]
28 ModelError(String),
29
30 #[error("Configuration error: {0}")]
31 ConfigError(String),
32
33 #[error("Orchestration error: {0}")]
34 OrchestrationError(String),
35
36 #[error("Timeout after {0} seconds")]
37 Timeout(u64),
38
39 #[error("Max iterations ({0}) exceeded")]
40 MaxIterationsExceeded(u32),
41
42 #[error("Cancelled by user")]
43 Cancelled,
44
45 #[error("Database error: {0}")]
46 DatabaseError(String),
47
48 #[error("Serialization error: {0}")]
49 SerializationError(String),
50
51 #[error("Network error: {0}")]
52 NetworkError(String),
53
54 #[error("Invalid state: {0}")]
55 InvalidState(String),
56
57 #[error(transparent)]
58 Other(#[from] anyhow::Error),
59}
60
61impl From<serde_json::Error> for AgencyError {
62 fn from(err: serde_json::Error) -> Self {
63 AgencyError::SerializationError(err.to_string())
64 }
65}
66
67impl From<rusqlite::Error> for AgencyError {
68 fn from(err: rusqlite::Error) -> Self {
69 AgencyError::DatabaseError(err.to_string())
70 }
71}
72
73pub type AgencyResult<T> = Result<T, AgencyError>;