llm_git/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum CommitGenError {
5   #[error("Git command failed: {0}")]
6   GitError(String),
7
8   #[error("API request failed (HTTP {status}): {body}")]
9   ApiError { status: u16, body: String },
10
11   #[error("API call failed after {retries} retries: {source}")]
12   ApiRetryExhausted {
13      retries: u32,
14      #[source]
15      source:  Box<Self>,
16   },
17
18   #[error("Validation failed: {0}")]
19   ValidationError(String),
20
21   #[error("No changes found in {mode} mode")]
22   NoChanges { mode: String },
23
24   #[error("Diff parsing failed: {0}")]
25   #[allow(dead_code, reason = "Reserved for future diff parsing error handling")]
26   DiffParseError(String),
27
28   #[error("Invalid commit type: {0}")]
29   InvalidCommitType(String),
30
31   #[error("Invalid scope format: {0}")]
32   InvalidScope(String),
33
34   #[error("Summary too long: {len} chars (max {max})")]
35   SummaryTooLong { len: usize, max: usize },
36
37   #[error("IO error: {0}")]
38   IoError(#[from] std::io::Error),
39
40   #[error("JSON error: {0}")]
41   JsonError(#[from] serde_json::Error),
42
43   #[error("HTTP error: {0}")]
44   HttpError(#[from] reqwest::Error),
45
46   #[error("Clipboard error: {0}")]
47   ClipboardError(#[from] arboard::Error),
48
49   #[error("{0}")]
50   Other(String),
51
52   #[error("Failed to parse changelog {path}: {reason}")]
53   ChangelogParseError { path: String, reason: String },
54
55   #[error("No [Unreleased] section found in {path}")]
56   NoUnreleasedSection { path: String },
57}
58
59pub type Result<T> = std::result::Result<T, CommitGenError>;