Skip to main content

syara_x/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum SyaraError {
5    #[error("file not found: {0}")]
6    FileNotFound(String),
7
8    #[error("parse error at line {line}: {message}")]
9    ParseError { line: usize, message: String },
10
11    #[error("duplicate identifier '{0}' in rule '{1}'")]
12    DuplicateIdentifier(String, String),
13
14    #[error("undefined identifier '{identifier}' in condition of rule '{rule}'")]
15    UndefinedIdentifier { identifier: String, rule: String },
16
17    #[error("invalid pattern '{pattern}': {reason}")]
18    InvalidPattern { pattern: String, reason: String },
19
20    #[error("condition parse error: {0}")]
21    ConditionParse(String),
22
23    #[error("component '{name}' not found: {kind}")]
24    ComponentNotFound { kind: String, name: String },
25
26    #[error("IO error: {0}")]
27    Io(#[from] std::io::Error),
28
29    #[error("semantic matching error: {0}")]
30    SemanticError(String),
31
32    #[error("classifier error: {0}")]
33    ClassifierError(String),
34
35    #[error("LLM error: {0}")]
36    LlmError(String),
37
38    #[error("phash error: {0}")]
39    PhashError(String),
40}