gglib_core/paths/
error.rs

1//! Path-related error types.
2//!
3//! Provides semantic errors for path operations without exposing
4//! implementation details or adapter-specific concerns.
5
6use std::path::PathBuf;
7use thiserror::Error;
8
9/// Errors that can occur during path resolution and directory operations.
10#[derive(Debug, Error)]
11pub enum PathError {
12    /// Could not determine the user's home directory.
13    #[error("Cannot determine home directory")]
14    NoHomeDir,
15
16    /// Could not determine the system data directory.
17    #[error("Cannot determine system data directory")]
18    NoDataDir,
19
20    /// A path was expected to be a directory but was not.
21    #[error("{0} exists but is not a directory")]
22    NotADirectory(PathBuf),
23
24    /// A directory does not exist and creation was not allowed.
25    #[error("Directory {0} does not exist")]
26    DirectoryNotFound(PathBuf),
27
28    /// Failed to create a directory.
29    #[error("Failed to create directory {path}: {reason}")]
30    CreateFailed { path: PathBuf, reason: String },
31
32    /// A directory is not writable.
33    #[error("Directory {path} is not writable: {reason}")]
34    NotWritable { path: PathBuf, reason: String },
35
36    /// An empty path was provided.
37    #[error("Path cannot be empty")]
38    EmptyPath,
39
40    /// Failed to read or write the environment file.
41    #[error("Failed to access env file {path}: {reason}")]
42    EnvFileError { path: PathBuf, reason: String },
43
44    /// Failed to get the current working directory.
45    #[error("Cannot determine current directory: {0}")]
46    CurrentDirError(String),
47}