Skip to main content

lightshuttle_secrets/
error.rs

1//! Error types for secret loading.
2
3use std::path::PathBuf;
4
5/// Errors that can occur while loading secrets.
6#[derive(Debug, thiserror::Error)]
7pub enum SecretError {
8    /// The `.env` file path was explicitly provided but does not exist.
9    #[error("env file not found: {0}")]
10    FileNotFound(PathBuf),
11
12    /// An I/O error occurred while reading the file.
13    #[error("failed to read env file {path}: {source}")]
14    Io {
15        /// Path to the file that caused the error.
16        path: PathBuf,
17        /// Underlying I/O error.
18        #[source]
19        source: std::io::Error,
20    },
21
22    /// A line in the file could not be parsed as `KEY=VALUE`.
23    #[error("invalid syntax in {path} at line {line}: {message}")]
24    InvalidSyntax {
25        /// Path to the file that caused the error.
26        path: PathBuf,
27        /// 1-based line number.
28        line: usize,
29        /// Description of the syntax problem.
30        message: String,
31    },
32}