Skip to main content

llm_inspect/
error.rs

1/// Errors returned while building an [`Inspector`](crate::Inspector) or an
2/// [`OutputValidator`](crate::OutputValidator).
3#[derive(Debug, thiserror::Error)]
4#[non_exhaustive]
5pub enum Error {
6    /// A rule's regular expression failed to compile.
7    #[error("invalid pattern in rule `{id}`: {source}")]
8    InvalidPattern {
9        /// The rule id.
10        id: String,
11        /// The underlying regex error.
12        #[source]
13        source: Box<regex::Error>,
14    },
15    /// Two rules share the same id.
16    #[error("duplicate rule id `{0}`")]
17    DuplicateRuleId(String),
18    /// A rule has an empty id.
19    #[error("rule at index {0} has an empty id")]
20    EmptyRuleId(usize),
21    /// The TOML rule file could not be parsed.
22    #[error("failed to parse rules: {0}")]
23    RulesParse(#[from] toml::de::Error),
24    /// The JSON Schema could not be compiled.
25    #[error("invalid JSON schema: {0}")]
26    InvalidSchema(String),
27    /// An allow-list pointer is malformed.
28    #[error("invalid allow-list pointer `{0}`: must start with '/'")]
29    InvalidPointer(String),
30}