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
39impl From<std::io::Error> for Error {
40 fn from(e: std::io::Error) -> Self {
41 Self::Io {
42 message: e.to_string(),
43 source: e,
44 }
45 }
46}
47
48pub type Result<T> = std::result::Result<T, Error>;