1use thiserror::Error;
7
8pub type Result<T> = std::result::Result<T, AcpError>;
10
11#[derive(Error, Debug)]
14pub enum AcpError {
15 #[error("IO error: {0}")]
17 Io(#[from] std::io::Error),
18
19 #[error("JSON error: {0}")]
21 Json(#[from] serde_json::Error),
22
23 #[error("Parse error: {message}")]
25 Parse {
26 message: String,
27 file: Option<String>,
28 line: Option<usize>,
29 },
30
31 #[error("File not found: {0}")]
33 FileNotFound(String),
34
35 #[error("Invalid configuration: {0}")]
37 Config(String),
38
39 #[error("Variable not found: {0}")]
41 VarNotFound(String),
42
43 #[error("Cycle detected in variable inheritance: {0}")]
45 CycleDetected(String),
46
47 #[error("Schema validation failed: {0}")]
49 SchemaValidation(String),
50
51 #[error("Semantic validation failed: {0}")]
53 SemanticValidation(String),
54
55 #[error("Unsupported language: {0}")]
57 UnsupportedLanguage(String),
58
59 #[error("Index error: {0}")]
61 Index(String),
62
63 #[error("{0}")]
65 Other(String),
66}
67
68impl AcpError {
69 pub fn parse(message: impl Into<String>) -> Self {
71 Self::Parse {
72 message: message.into(),
73 file: None,
74 line: None,
75 }
76 }
77
78 pub fn parse_at(message: impl Into<String>, file: impl Into<String>, line: usize) -> Self {
80 Self::Parse {
81 message: message.into(),
82 file: Some(file.into()),
83 line: Some(line),
84 }
85 }
86}