claude_pool/error.rs
1//! Error types for claude-pool.
2
3/// Errors that can occur in claude-pool operations.
4#[derive(Debug, thiserror::Error)]
5pub enum Error {
6 /// A slot with the given ID was not found.
7 #[error("slot not found: {0}")]
8 SlotNotFound(String),
9
10 /// A task with the given ID was not found.
11 #[error("task not found: {0}")]
12 TaskNotFound(String),
13
14 /// No slot became available within the timeout period.
15 #[error("no slot available after waiting {timeout_secs}s")]
16 NoSlotAvailable { timeout_secs: u64 },
17
18 /// The pool has been shut down and is no longer accepting work.
19 #[error("pool is shut down")]
20 PoolShutdown,
21
22 /// Budget limit has been reached.
23 #[error("budget exhausted: spent {spent_microdollars} of {limit_microdollars} microdollars")]
24 BudgetExhausted {
25 /// Microdollars spent so far.
26 spent_microdollars: u64,
27 /// Microdollars budget limit.
28 limit_microdollars: u64,
29 },
30
31 /// An error from the underlying Claude CLI wrapper.
32 #[error("claude-wrapper error: {0}")]
33 Wrapper(#[from] claude_wrapper::Error),
34
35 /// JSON serialization/deserialization error.
36 #[error("json error: {0}")]
37 Json(#[from] serde_json::Error),
38
39 /// The Claude CLI appears to have stalled on a permission prompt.
40 ///
41 /// This occurs when the CLI requests tool approval and no human is present
42 /// to respond. The slot blocks on stdin until it times out or is killed.
43 #[error(
44 "permission prompt detected: {tool_name}. Add it to allowed_tools or use a broader permission mode"
45 )]
46 PermissionPromptDetected {
47 /// The tool or permission that was requested (best-effort extraction).
48 tool_name: String,
49 /// The raw stderr that triggered detection.
50 stderr: String,
51 /// The slot that was blocked.
52 slot_id: String,
53 },
54
55 /// Filesystem I/O error.
56 #[error("io error: {0}")]
57 Io(#[from] std::io::Error),
58
59 /// An error from the store backend.
60 #[error("store error: {0}")]
61 Store(String),
62}
63
64/// A convenience type alias for `Result<T, Error>`.
65pub type Result<T> = std::result::Result<T, Error>;