Skip to main content

trojan_rules/
error.rs

1//! Error types for the rule engine.
2
3use thiserror::Error;
4
5/// Errors that can occur in the rule engine.
6#[derive(Error, Debug)]
7pub enum RulesError {
8    #[error("parse error: {0}")]
9    Parse(String),
10
11    #[error("invalid rule type: {0}")]
12    InvalidRuleType(String),
13
14    #[error("invalid CIDR: {0}")]
15    InvalidCidr(String),
16
17    #[error("io error: {0}")]
18    Io(#[from] std::io::Error),
19
20    #[error("yaml parse error: {0}")]
21    Yaml(#[from] serde_yaml::Error),
22
23    #[error("no FINAL rule defined")]
24    NoFinalRule,
25
26    #[error("unknown rule-set: {0}")]
27    UnknownRuleSet(String),
28
29    #[error("rule provider error: {0}")]
30    Provider(String),
31
32    #[error("geoip error: {0}")]
33    GeoIp(String),
34
35    #[error("http error: {0}")]
36    Http(String),
37}