Skip to main content

stack_profile/
error.rs

1use std::path::PathBuf;
2
3/// Errors that can occur when reading or writing profile files.
4#[derive(Debug, thiserror::Error)]
5#[non_exhaustive]
6pub enum ProfileError {
7    /// An I/O error occurred while reading or writing a profile file.
8    #[error("I/O error: {0}")]
9    Io(#[from] std::io::Error),
10    /// A profile file contained invalid JSON.
11    #[error("JSON error: {0}")]
12    Json(#[from] serde_json::Error),
13    /// The user's home directory could not be determined.
14    #[error("Could not determine home directory")]
15    HomeDirNotFound,
16    /// The requested profile file was not found.
17    #[error("Profile not found: {path}")]
18    NotFound {
19        /// The path that was looked up.
20        path: PathBuf,
21    },
22    /// The filename is invalid (contains path separators, `..`, or is absolute).
23    #[error("Invalid profile filename: {0}")]
24    InvalidFilename(String),
25}