Skip to main content

hermes_bot/
error.rs

1use thiserror::Error;
2
3/// Errors that can occur in Hermes.
4#[derive(Debug, Error)]
5pub enum HermesError {
6    /// Configuration file error (missing, invalid, etc.)
7    #[error("Configuration error: {0}")]
8    Config(String),
9
10    /// Session not found for the given thread
11    #[error("Session not found for thread '{0}'")]
12    SessionNotFound(String),
13
14    /// Claude CLI binary not found in PATH
15    #[error(
16        "Claude CLI not found in PATH. Install it from: https://docs.anthropic.com/en/docs/claude-code"
17    )]
18    ClaudeNotFound,
19
20    /// Failed to spawn the Claude CLI process
21    #[error("Failed to spawn Claude CLI: {reason}")]
22    AgentSpawnFailed { reason: String },
23
24    /// Slack API call failed
25    #[error("Slack API error: {0}")]
26    SlackApi(String),
27
28    /// Filesystem I/O error
29    #[error("IO error: {0}")]
30    Io(#[from] std::io::Error),
31
32    /// JSON serialization/deserialization error
33    #[error("JSON error: {0}")]
34    Json(#[from] serde_json::Error),
35
36    /// TOML configuration parse error
37    #[error("TOML parse error: {0}")]
38    Toml(#[from] toml::de::Error),
39
40    /// SQLite database error
41    #[error("Database error: {0}")]
42    Database(#[from] rusqlite::Error),
43}
44
45pub type Result<T> = std::result::Result<T, HermesError>;