reflex/config/error.rs
1//! Configuration error types.
2
3use std::path::PathBuf;
4use thiserror::Error;
5
6/// Errors that can occur during configuration loading and validation.
7#[derive(Debug, Error)]
8pub enum ConfigError {
9 /// Port value is outside valid range (1-65535).
10 #[error("invalid port '{value}': must be between 1 and 65535")]
11 InvalidPort {
12 /// Original string value.
13 value: String,
14 },
15
16 /// Port string could not be parsed as a number.
17 #[error("failed to parse port '{value}': {source}")]
18 PortParseError {
19 /// Original string value.
20 value: String,
21 #[source]
22 /// Parse error.
23 source: std::num::ParseIntError,
24 },
25
26 /// Bind address string could not be parsed.
27 #[error("failed to parse bind address '{value}': {source}")]
28 InvalidBindAddr {
29 /// Original string value.
30 value: String,
31 #[source]
32 /// Parse error.
33 source: std::net::AddrParseError,
34 },
35
36 /// A required environment variable was not set.
37 /// (Reserved for stricter validation policies.)
38 #[error("missing required environment variable: {name}")]
39 MissingEnvVar {
40 /// Environment variable name.
41 name: &'static str,
42 },
43
44 /// Specified path does not exist on the filesystem.
45 #[error("path does not exist: {path}")]
46 PathNotFound {
47 /// Path that was missing.
48 path: PathBuf,
49 },
50
51 /// Path exists but is not a file (when a file was expected).
52 #[error("path is not a file: {path}")]
53 NotAFile {
54 /// Path that was not a file.
55 path: PathBuf,
56 },
57
58 /// Path exists but is not a directory (when a directory was expected).
59 #[error("path is not a directory: {path}")]
60 NotADirectory {
61 /// Path that was not a directory.
62 path: PathBuf,
63 },
64}