1use thiserror::Error;
4
5#[derive(Error, Debug)]
7pub enum AgentError {
8 #[error("Agent not found: {0}")]
9 AgentNotFound(crate::types::AgentId),
10
11 #[error("Failed to send message: {0}")]
12 SendError(String),
13
14 #[error("Processing error: {0}")]
15 ProcessingError(String),
16
17 #[error("Configuration error: {0}")]
18 ConfigError(String),
19
20 #[error("State error: {0}")]
21 StateError(String),
22
23 #[error("Maximum iterations exceeded")]
24 MaxIterationsExceeded,
25
26 #[error("Tool error: {0}")]
27 ToolError(#[from] ToolError),
28
29 #[error("LLM error: {0}")]
30 LLMError(#[from] LLMError),
31
32 #[error("Memory error: {0}")]
33 MemoryError(#[from] MemoryError),
34}
35
36#[derive(Error, Debug)]
38pub enum ToolError {
39 #[error("Tool not found: {0}")]
40 NotFound(String),
41
42 #[error("Invalid arguments: {0}")]
43 InvalidArguments(String),
44
45 #[error("Execution failed: {0}")]
46 ExecutionFailed(String),
47
48 #[error("Execution error: {0}")]
49 Execution(String),
50
51 #[error("Validation failed: {0}")]
52 ValidationFailed(String),
53
54 #[error("Timeout: {0}")]
55 Timeout(String),
56
57 #[error("Timeout: operation took longer than {0}ms")]
58 TimeoutMs(u64),
59
60 #[error("Permission denied: {0}")]
61 PermissionDenied(String),
62
63 #[error("Circuit breaker open for tool: {0}")]
64 CircuitOpen(String),
65}
66
67#[derive(Error, Debug)]
69pub enum LLMError {
70 #[error("API error: {0}")]
71 ApiError(String),
72
73 #[error("Invalid response: {0}")]
74 InvalidResponse(String),
75
76 #[error("Rate limit exceeded")]
77 RateLimitExceeded,
78
79 #[error("Authentication failed: {0}")]
80 AuthenticationFailed(String),
81
82 #[error("Network error: {0}")]
83 NetworkError(String),
84
85 #[error("Timeout: request took longer than {0}ms")]
86 Timeout(u64),
87
88 #[error("Token limit exceeded: {0}/{1}")]
89 TokenLimitExceeded(usize, usize),
90
91 #[error("Model not available: {0}")]
92 ModelNotAvailable(String),
93
94 #[error("Serialization error: {0}")]
95 SerializationError(String),
96
97 #[error("Validation error: {0}")]
98 ValidationError(String),
99}
100
101#[derive(Error, Debug)]
103pub enum CrewError {
104 #[error("Task not found: {0}")]
105 TaskNotFound(String),
106
107 #[error("Circular dependency detected in tasks")]
108 CircularDependency,
109
110 #[error("No agent available for task: {0}")]
111 NoAgentAvailable(String),
112
113 #[error("Task execution failed: {0}")]
114 TaskExecutionFailed(String),
115
116 #[error("Execution failed: {0}")]
117 ExecutionFailed(String),
118
119 #[error("Invalid configuration: {0}")]
120 InvalidConfiguration(String),
121
122 #[error("Agent error: {0}")]
123 AgentError(#[from] AgentError),
124}
125
126#[derive(Error, Debug)]
128pub enum MemoryError {
129 #[error("Memory limit exceeded: {0}/{1} bytes")]
130 LimitExceeded(usize, usize),
131
132 #[error("Capacity exceeded: current={current}, required={required}, max={max}")]
133 CapacityExceeded {
134 current: usize,
135 required: usize,
136 max: usize,
137 },
138
139 #[error("Persistence error: {0}")]
140 PersistenceError(String),
141
142 #[error("Serialization error: {0}")]
143 SerializationError(String),
144
145 #[error("Storage error: {0}")]
146 StorageError(String),
147
148 #[error("Session not found: {0}")]
149 SessionNotFound(String),
150
151 #[error("Not found: {0}")]
152 NotFound(String),
153}