1use thiserror::Error;
2
3pub type Result<T> = std::result::Result<T, ShieldError>;
4
5#[derive(Error, Debug)]
6pub enum ShieldError {
7 #[error("Parse error in {file}: {message}")]
8 Parse { file: String, message: String },
9
10 #[error("Adapter error ({framework}): {message}")]
11 Adapter { framework: String, message: String },
12
13 #[error("No suitable adapter found for directory: {0}")]
14 NoAdapter(String),
15
16 #[error("Configuration error: {0}")]
17 Config(String),
18
19 #[error("Rule error ({rule_id}): {message}")]
20 Rule { rule_id: String, message: String },
21
22 #[error("Output error: {0}")]
23 Output(String),
24
25 #[error("IO error: {0}")]
26 Io(#[from] std::io::Error),
27
28 #[error("JSON error: {0}")]
29 Json(#[from] serde_json::Error),
30
31 #[error("TOML parse error: {0}")]
32 Toml(#[from] toml::de::Error),
33
34 #[error("Internal error: {0}")]
35 Internal(String),
36}
37
38impl ShieldError {
39 pub fn exit_code(&self) -> i32 {
40 2
41 }
42}