ast_doc_core/error.rs
1//! Error types for the ast-doc pipeline.
2
3/// Errors that can occur during the ast-doc pipeline.
4#[derive(Debug, thiserror::Error)]
5pub enum AstDocError {
6 /// The token budget is exceeded even with minimum strategies.
7 #[error("Budget exceeded: {message}")]
8 BudgetExceeded {
9 /// Human-readable explanation.
10 message: String,
11 },
12
13 /// An unsupported language was requested.
14 #[error("Unsupported language: {language}")]
15 UnsupportedLanguage {
16 /// The language identifier that was not recognized.
17 language: String,
18 },
19
20 /// A file could not be read.
21 #[error("Failed to read file {path}: {source}")]
22 FileRead {
23 /// Path to the file.
24 path: std::path::PathBuf,
25 /// Underlying I/O error.
26 source: std::io::Error,
27 },
28
29 /// A tree-sitter parse error.
30 #[error("Parse error in {path}: {message}")]
31 Parse {
32 /// Path to the file.
33 path: std::path::PathBuf,
34 /// Error description.
35 message: String,
36 },
37
38 /// Git operation failed.
39 #[error("Git error: {0}")]
40 Git(#[from] git2::Error),
41
42 /// Glob pattern compilation failed.
43 #[error("Invalid glob pattern: {0}")]
44 InvalidGlob(#[from] globset::Error),
45
46 /// Generic I/O error.
47 #[error(transparent)]
48 Io(#[from] std::io::Error),
49
50 /// JSON serialization error.
51 #[error(transparent)]
52 Json(#[from] serde_json::Error),
53}