-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy patherror.rs
More file actions
88 lines (64 loc) · 2.17 KB
/
Copy patherror.rs
File metadata and controls
88 lines (64 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
use std::path::PathBuf;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum IaCGeneratorError {
#[error("Project analysis failed: {0}")]
Analysis(#[from] AnalysisError),
#[error("IaC generation failed: {0}")]
Generation(#[from] GeneratorError),
#[error("Configuration error: {0}")]
Config(#[from] ConfigError),
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("Walk directory error: {0}")]
WalkDir(#[from] walkdir::Error),
#[error("JSON serialization error: {0}")]
Json(#[from] serde_json::Error),
#[error("Security error: {0}")]
Security(#[from] SecurityError),
#[error("Agent error: {0}")]
Agent(#[from] crate::agent::AgentError),
}
#[derive(Error, Debug)]
pub enum AnalysisError {
#[error("Unsupported project type: {0}")]
UnsupportedProject(String),
#[error("Failed to detect language in {path}")]
LanguageDetection { path: PathBuf },
#[error("Dependency parsing failed for {file}: {reason}")]
DependencyParsing { file: String, reason: String },
#[error("Framework detection failed: {0}")]
FrameworkDetection(String),
#[error("Invalid project structure: {0}")]
InvalidStructure(String),
}
#[derive(Error, Debug)]
pub enum GeneratorError {
#[error("Template rendering failed: {0}")]
TemplateRendering(String),
#[error("Unsupported generator type: {0}")]
UnsupportedGenerator(String),
#[error("Output file creation failed: {path}")]
OutputCreation { path: PathBuf },
#[error("Invalid generation context: {0}")]
InvalidContext(String),
}
#[derive(Error, Debug)]
pub enum ConfigError {
#[error("Invalid configuration file: {0}")]
InvalidFile(String),
#[error("Missing required configuration: {0}")]
MissingConfig(String),
#[error("Configuration parsing failed: {0}")]
ParsingFailed(String),
}
#[derive(Error, Debug)]
pub enum SecurityError {
#[error("Invalid path: path traversal detected")]
PathTraversal,
#[error("Invalid path: {0}")]
InvalidPath(String),
#[error("Insufficient permissions: {0}")]
InsufficientPermissions(String),
}
pub type Result<T> = std::result::Result<T, IaCGeneratorError>;