feature_flag/error.rs
1//! Crate-wide error type.
2
3use std::path::PathBuf;
4
5use thiserror::Error;
6
7/// Anything that can go wrong inside the crate.
8#[derive(Debug, Error)]
9pub enum FeatureFlagError {
10 /// Failed to parse a JSON flagset.
11 #[error("failed to parse flagset: {0}")]
12 Parse(#[from] serde_json::Error),
13
14 /// Failed to read a flagset file.
15 #[error("failed to read flagset {path:?}: {source}")]
16 Io {
17 /// Path the caller was reading.
18 path: PathBuf,
19 /// Underlying io error.
20 #[source]
21 source: std::io::Error,
22 },
23
24 /// The flagset is structurally valid but invalid as a logical config
25 /// (e.g. a rollout that totals > 100, a variant referenced from a rule
26 /// that doesn't appear in the flag's variants list).
27 #[error("invalid flagset: {0}")]
28 Invalid(String),
29
30 /// Asked to evaluate a flag that isn't in the loaded flagset. The caller's
31 /// default value is returned via the `Evaluation::Default` outcome.
32 #[error("unknown flag: {0}")]
33 UnknownFlag(String),
34}