1use thiserror::Error;
4
5#[derive(Error, Debug)]
7pub enum ClaudeError {
8 #[error(
10 "Claude API key not found. Set CLAUDE_API_KEY or ANTHROPIC_API_KEY environment variable"
11 )]
12 ApiKeyNotFound,
13
14 #[error("Claude API request failed: {0}")]
16 ApiRequestFailed(String),
17
18 #[error("Invalid response format from Claude API: {0}")]
20 InvalidResponseFormat(String),
21
22 #[error("Failed to parse amendments from Claude response: {0}")]
24 AmendmentParsingFailed(String),
25
26 #[error(
28 "Prompt too large for model '{model}': estimated {estimated_tokens} tokens, \
29 but only {max_tokens} input tokens available"
30 )]
31 PromptTooLarge {
32 estimated_tokens: usize,
34 max_tokens: usize,
36 model: String,
38 },
39
40 #[error("Rate limit exceeded. Please try again later")]
42 RateLimitExceeded,
43
44 #[error("Network error: {0}")]
46 NetworkError(String),
47
48 #[error("Subprocess binary not found: {0}")]
50 SubprocessBinaryMissing(String),
51
52 #[error("Failed to spawn subprocess: {0}")]
54 SubprocessSpawnFailed(String),
55
56 #[error("Subprocess timed out after {secs} seconds")]
58 SubprocessTimeout {
59 secs: u64,
61 },
62
63 #[error("Subprocess output exceeded limit of {limit} bytes")]
65 SubprocessOutputTooLarge {
66 limit: usize,
68 },
69
70 #[error("Subprocess produced invalid JSON output: {0}")]
72 SubprocessJsonParseFailed(String),
73}
74
75