Skip to main content

folders/
error.rs

1//! Error types for base-directory resolution
2
3/// Reason a base directory could not be resolved.
4#[derive(Debug, Clone, PartialEq, Eq)]
5pub enum Error {
6    /// Home directory could not be determined
7    ///
8    /// Unix: `$HOME`
9    /// Windows: `%USERPROFILE%`
10    NoHome,
11
12    /// No runtime directory set
13    ///
14    /// Only relevant on UNIX
15    NoRuntime,
16}
17
18/// Result alias for fallible base-directory resolution.
19pub type Result<T> = std::result::Result<T, Error>;
20
21impl std::fmt::Display for Error {
22    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23        match self {
24            Error::NoHome => write!(f, "could not determine home directory"),
25            Error::NoRuntime => write!(f, "could not determine runtime directory"),
26        }
27    }
28}
29
30impl std::error::Error for Error {}