Skip to main content

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    /// An error from the store backend.
40    #[error("store error: {0}")]
41    Store(String),
42}
43
44/// A convenience type alias for `Result<T, Error>`.
45pub type Result<T> = std::result::Result<T, Error>;