1#![allow(clippy::enum_variant_names)]
4
5use std::path::PathBuf;
6
7#[derive(Debug, thiserror::Error)]
9pub enum Error {
10 #[error("Team '{name}' not found")]
11 TeamNotFound { name: String },
12
13 #[error("Team '{name}' already exists")]
14 TeamAlreadyExists { name: String },
15
16 #[error("Team '{name}' has active teammates, cannot delete")]
17 TeamHasActiveMembers { name: String },
18
19 #[error("Member '{member}' not found in team '{team}'")]
20 MemberNotFound { team: String, member: String },
21
22 #[error("Member '{member}' already exists in team '{team}'")]
23 MemberAlreadyExists { team: String, member: String },
24
25 #[error("Task '{id}' not found in team '{team}'")]
26 TaskNotFound { team: String, id: String },
27
28 #[error("Invalid task status transition: {from} -> {to}")]
29 InvalidStatusTransition { from: String, to: String },
30
31 #[error("Task '{id}' is blocked by: {blocked_by:?}")]
32 TaskBlocked { id: String, blocked_by: Vec<String> },
33
34 #[error("Adding dependency would create a cycle: {from} -> {to}")]
35 CycleDetected { from: String, to: String },
36
37 #[error("Inbox for agent '{agent}' not found in team '{team}'")]
38 InboxNotFound { team: String, agent: String },
39
40 #[error("Agent '{name}' is not alive")]
41 AgentNotAlive { name: String },
42
43 #[error("Agent '{name}' failed to spawn: {reason}")]
44 SpawnFailed { name: String, reason: String },
45
46 #[error("Backend '{backend}' not configured")]
47 BackendNotConfigured { backend: String },
48
49 #[error("CLI not found: {name}")]
50 CliNotFound { name: String },
51
52 #[error("Invalid name '{name}': {reason}")]
53 InvalidName { name: String, reason: String },
54
55 #[error("File lock failed on {path}: {reason}")]
56 LockFailed { path: PathBuf, reason: String },
57
58 #[error("Atomic write failed for {path}: {reason}")]
59 AtomicWriteFailed { path: PathBuf, reason: String },
60
61 #[error("IO error: {0}")]
62 Io(#[from] std::io::Error),
63
64 #[error("JSON error: {0}")]
65 Json(#[from] serde_json::Error),
66
67 #[error("SDK error: {0}")]
68 Sdk(#[from] cc_sdk::SdkError),
69
70 #[error("Timeout after {seconds}s")]
71 Timeout { seconds: u64 },
72
73 #[error("Background task join error: {0}")]
74 JoinError(String),
75
76 #[error("Codex protocol error: {reason}")]
77 CodexProtocol { reason: String },
78
79 #[error("Gemini CLI error: {reason}")]
80 GeminiCli { reason: String },
81
82 #[error("Consensus failed: {reason}")]
83 ConsensusFailed { reason: String },
84
85 #[cfg(feature = "checkpoint")]
87 #[error("Git error: {0}")]
88 Git(#[from] git2::Error),
89
90 #[error("Checkpoint not found for commit {sha}")]
91 CheckpointNotFound { sha: String },
92
93 #[error("Path is not a git repository: {path}")]
94 NotAGitRepo { path: std::path::PathBuf },
95
96 #[error("Checkpoint error: {reason}")]
97 CheckpointError { reason: String },
98
99 #[error("{0}")]
100 Other(String),
101}
102
103pub type Result<T> = std::result::Result<T, Error>;