volition_core/errors.rs
1// volition-agent-core/src/errors.rs
2use thiserror::Error;
3
4/// Errors that can occur during Agent execution.
5#[derive(Error, Debug)]
6pub enum AgentError {
7 /// Error related to configuration loading or validation.
8 #[error("Configuration Error: {0}")]
9 Config(String),
10
11 /// Error during interaction with the AI model API.
12 #[error("API Error: {0}")]
13 Api(#[source] anyhow::Error),
14
15 /// Error originating from within an agent strategy.
16 #[error("Strategy Error: {0}")]
17 Strategy(String),
18
19 /// Error related to tool definition or execution (Old system).
20 #[error("Tool Error: {0}")]
21 Tool(String),
22
23 /// Error related to MCP connection or tool call (New system).
24 #[error("MCP Error: {0}")]
25 Mcp(#[source] anyhow::Error), // Added Mcp variant
26
27 /// Error during task delegation (if implemented).
28 #[error("Delegation Error: {0}")]
29 Delegation(String),
30
31 /// Error during user interaction.
32 #[error("User Interaction Error: {0}")]
33 Ui(#[source] anyhow::Error),
34}
35
36// Helper implementations (optional)
37impl AgentError {
38 pub fn config(msg: impl Into<String>) -> Self {
39 AgentError::Config(msg.into())
40 }
41 // Keep other helpers if needed
42}