coda_core/error.rs
1//! Error types for the core engine.
2//!
3//! Defines `CoreError` as the primary error type for all operations
4//! within `coda-core`.
5
6use thiserror::Error;
7
8/// Error type for coda-core operations.
9///
10/// Variants are grouped by subsystem: agent, git/gh external CLI, planning
11/// workflow, state management, I/O, serialization, and configuration.
12#[derive(Debug, Error)]
13#[non_exhaustive]
14pub enum CoreError {
15 /// An error from the Claude Agent SDK or agent execution.
16 ///
17 /// Covers both SDK-level failures (connection, streaming) and
18 /// logical agent errors (empty responses, unexpected phases).
19 #[error("Agent error: {0}")]
20 AgentError(String),
21
22 /// An error from the prompt template manager.
23 #[error("Prompt error: {0}")]
24 PromptError(#[from] coda_pm::PromptError),
25
26 /// An I/O error from file system operations.
27 #[error("IO error: {0}")]
28 IoError(#[from] std::io::Error),
29
30 /// A configuration error (invalid or missing config).
31 #[error("Config error: {0}")]
32 ConfigError(String),
33
34 /// A state file error (invalid or missing state).
35 #[error("State error: {0}")]
36 StateError(String),
37
38 /// A planning workflow error (e.g. finalizing without approval).
39 #[error("Plan error: {0}")]
40 PlanError(String),
41
42 /// A git/gh external CLI operation error.
43 #[error("Git error: {0}")]
44 GitError(String),
45
46 /// A YAML serialization/deserialization error.
47 #[error("YAML error: {0}")]
48 YamlError(#[from] serde_yaml::Error),
49
50 /// A generic error from anyhow.
51 #[error(transparent)]
52 AnyhowError(#[from] anyhow::Error),
53}