//! Error types for user-facing CLI failures.

use std::path::PathBuf;

/// Convenient result type for timefs operations.
pub type Result<T> = std::result::Result<T, Error>;

/// Errors surfaced by the CLI shell before the FUSE daemon is started.
#[derive(Debug, thiserror::Error)]
pub enum Error {
    /// The supplied path does not exist.
    #[error("{label} path does not exist: {path}")]
    PathDoesNotExist { label: &'static str, path: PathBuf },

    /// The supplied path exists but is not a directory.
    #[error("{label} path is not a directory: {path}")]
    PathIsNotDirectory { label: &'static str, path: PathBuf },

    /// Probing the supplied path failed.
    #[error("failed to inspect {label} path {path}: {source}")]
    PathProbeFailed {
        label: &'static str,
        path: PathBuf,
        source: std::io::Error,
    },

    /// Canonicalizing the supplied path failed.
    #[error("failed to canonicalize {label} path {path}: {source}")]
    PathCanonicalizeFailed {
        label: &'static str,
        path: PathBuf,
        source: std::io::Error,
    },
}
