Skip to main content

actrpc_interceptor/interceptors/policy/
error.rs

1use std::path::PathBuf;
2
3#[derive(Debug, thiserror::Error)]
4pub enum PolicyError {
5    #[error("failed to read policy config file {path}: {source}")]
6    ConfigRead {
7        path: PathBuf,
8        #[source]
9        source: std::io::Error,
10    },
11
12    #[error("unsupported policy config file format for {path}")]
13    UnsupportedConfigFormat { path: PathBuf },
14
15    #[error("failed to deserialize TOML policy config {path}: {source}")]
16    ConfigDeserializeToml {
17        path: PathBuf,
18        #[source]
19        source: toml::de::Error,
20    },
21
22    #[error("failed to deserialize YAML policy config {path}: {source}")]
23    ConfigDeserializeYaml {
24        path: PathBuf,
25        #[source]
26        source: serde_yaml::Error,
27    },
28
29    #[error("invalid policy config: {message}")]
30    InvalidConfig { message: String },
31
32    #[error("duplicate policy rule name: {name}")]
33    DuplicateRuleName { name: String },
34
35    #[error("invalid regex in rule {rule}: {source}")]
36    InvalidRegex {
37        rule: String,
38        #[source]
39        source: regex::Error,
40    },
41
42    #[error("invalid glob in rule {rule}: {source}")]
43    InvalidGlob {
44        rule: String,
45        #[source]
46        source: globset::Error,
47    },
48
49    #[error("failed to encode policy effect action: {source}")]
50    ActionEncoding {
51        #[source]
52        source: serde_json::Error,
53    },
54
55    #[error("invalid review result: {message}")]
56    InvalidReviewResult { message: String },
57}