configbuilder_pattern_substitution/
error.rs1use std::fmt;
2
3#[derive(Debug, Clone, PartialEq)]
5pub enum SubstitutionError {
6 VariableNotFound {
8 var_name: String,
10 location: String,
12 },
13 VariableRejected {
15 var_name: String,
17 reason: String,
19 policy: String,
21 },
22 InvalidSubstitutionSyntax {
24 value: String,
26 reason: String,
28 },
29}
30
31impl fmt::Display for SubstitutionError {
32 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
33 match self {
34 SubstitutionError::VariableNotFound { var_name, location } => write!(
35 f,
36 "Environment variable '{}' referenced in config (at {}) but not found",
37 var_name, location
38 ),
39 SubstitutionError::VariableRejected {
40 var_name,
41 reason,
42 policy,
43 } => write!(
44 f,
45 "Environment variable '{}' not allowed by validation policy ({}): {}",
46 var_name, policy, reason
47 ),
48 SubstitutionError::InvalidSubstitutionSyntax { value, reason } => {
49 write!(f, "Invalid substitution syntax in '{}': {}", value, reason)
50 }
51 }
52 }
53}
54
55impl std::error::Error for SubstitutionError {}