bamboo_agent/error.rs
1//! Error types for Bamboo
2//!
3//! This module defines the main error type used throughout the Bamboo application
4//! for handling various failure scenarios.
5
6use thiserror::Error;
7
8/// Main error type for Bamboo operations
9///
10/// This enum represents all possible errors that can occur when working
11/// with the Bamboo system, including configuration, I/O, serialization,
12/// HTTP server, process management, and agent-related errors.
13#[derive(Debug, Error)]
14pub enum BambooError {
15 /// Configuration-related errors (invalid settings, missing config files, etc.)
16 #[error("Configuration error: {0}")]
17 Config(String),
18
19 /// I/O errors from file system operations
20 #[error("IO error: {0}")]
21 Io(#[from] std::io::Error),
22
23 /// Serialization/deserialization errors (JSON, YAML, etc.)
24 #[error("Serialization error: {0}")]
25 Serialization(#[from] serde_json::Error),
26
27 /// HTTP server startup and runtime errors
28 #[error("HTTP server error: {0}")]
29 HttpServer(String),
30
31 /// Process management errors (spawning, monitoring, etc.)
32 #[error("Process management error: {0}")]
33 ProcessManagement(String),
34
35 /// Agent execution errors (LLM communication, tool execution, etc.)
36 #[error("Agent error: {0}")]
37 Agent(String),
38
39 /// Generic errors from anyhow
40 #[error("{0}")]
41 Other(#[from] anyhow::Error),
42}
43
44/// Convenient result type alias for Bamboo operations
45pub type Result<T> = std::result::Result<T, BambooError>;