agcodex_execpolicy/
error.rs

1use std::path::PathBuf;
2
3use serde::Serialize;
4
5use crate::arg_matcher::ArgMatcher;
6use crate::arg_resolver::PositionalArg;
7use serde_with::DisplayFromStr;
8use serde_with::serde_as;
9
10pub type Result<T> = std::result::Result<T, Error>;
11
12#[serde_as]
13#[derive(Debug, Eq, PartialEq, Serialize)]
14#[serde(tag = "type")]
15pub enum Error {
16    NoSpecForProgram {
17        program: String,
18    },
19    OptionMissingValue {
20        program: String,
21        option: String,
22    },
23    OptionFollowedByOptionInsteadOfValue {
24        program: String,
25        option: String,
26        value: String,
27    },
28    UnknownOption {
29        program: String,
30        option: String,
31    },
32    UnexpectedArguments {
33        program: String,
34        args: Vec<PositionalArg>,
35    },
36    DoubleDashNotSupportedYet {
37        program: String,
38    },
39    MultipleVarargPatterns {
40        program: String,
41        first: ArgMatcher,
42        second: ArgMatcher,
43    },
44    RangeStartExceedsEnd {
45        start: usize,
46        end: usize,
47    },
48    RangeEndOutOfBounds {
49        end: usize,
50        len: usize,
51    },
52    PrefixOverlapsSuffix {},
53    NotEnoughArgs {
54        program: String,
55        args: Vec<PositionalArg>,
56        arg_patterns: Vec<ArgMatcher>,
57    },
58    InternalInvariantViolation {
59        message: String,
60    },
61    VarargMatcherDidNotMatchAnything {
62        program: String,
63        matcher: ArgMatcher,
64    },
65    EmptyFileName {},
66    LiteralValueDidNotMatch {
67        expected: String,
68        actual: String,
69    },
70    InvalidPositiveInteger {
71        value: String,
72    },
73    MissingRequiredOptions {
74        program: String,
75        options: Vec<String>,
76    },
77    SedCommandNotProvablySafe {
78        command: String,
79    },
80    ReadablePathNotInReadableFolders {
81        file: PathBuf,
82        folders: Vec<PathBuf>,
83    },
84    WriteablePathNotInWriteableFolders {
85        file: PathBuf,
86        folders: Vec<PathBuf>,
87    },
88    CannotCheckRelativePath {
89        file: PathBuf,
90    },
91    CannotCanonicalizePath {
92        file: String,
93        #[serde_as(as = "DisplayFromStr")]
94        error: std::io::ErrorKind,
95    },
96}