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    /// No current workspace is set but a workspace-scoped operation was attempted.
26    #[error("No current workspace set. Run `stash login` or `stash workspaces switch` first.")]
27    NoCurrentWorkspace,
28    /// The workspace ID is invalid (not a 16-character base32 string).
29    #[error("Invalid workspace ID: {0}")]
30    InvalidWorkspaceId(String),
31    /// The workspace has no local profile data (not logged in).
32    #[error("Workspace not found: {0}. Log in to this workspace first.")]
33    WorkspaceNotFound(String),
34}