1#[derive(Debug, thiserror::Error)]
3pub enum Error {
4 #[error("claude binary not found in PATH")]
6 NotFound,
7
8 #[error("claude command failed: {command} (exit code {exit_code})")]
10 CommandFailed {
11 command: String,
12 exit_code: i32,
13 stdout: String,
14 stderr: String,
15 },
16
17 #[error("io error: {message}")]
19 Io {
20 message: String,
21 #[source]
22 source: std::io::Error,
23 },
24
25 #[error("claude command timed out after {timeout_seconds}s")]
27 Timeout { timeout_seconds: u64 },
28
29 #[cfg(feature = "json")]
31 #[error("json parse error: {message}")]
32 Json {
33 message: String,
34 #[source]
35 source: serde_json::Error,
36 },
37
38 #[error("CLI version {found} does not meet minimum requirement {minimum}")]
40 VersionMismatch {
41 found: crate::version::CliVersion,
42 minimum: crate::version::CliVersion,
43 },
44}
45
46impl From<std::io::Error> for Error {
47 fn from(e: std::io::Error) -> Self {
48 Self::Io {
49 message: e.to_string(),
50 source: e,
51 }
52 }
53}
54
55pub type Result<T> = std::result::Result<T, Error>;