use std::path::PathBuf;
use thiserror::Error;

/// Result type alias using fsindex's Error type.
pub type Result<T> = std::result::Result<T, Error>;

/// Errors that can occur during filesystem indexing.
#[derive(Error, Debug)]
pub enum Error {
    #[error("IO error at '{path}': {source}")]
    Io {
        path: PathBuf,
        #[source]
        source: std::io::Error,
    },

    #[error("Path does not exist: {0}")]
    PathNotFound(PathBuf),

    #[error("Path is not a directory: {0}")]
    NotADirectory(PathBuf),

    #[error("Failed to read file content: {0}")]
    ReadContent(#[from] std::io::Error),

    #[error("File watcher error: {0}")]
    Watcher(#[from] notify::Error),

    #[error("Walker error: {0}")]
    Walk(#[from] ignore::Error),

    #[error("Failed to serialize state: {0}")]
    Serialize(String),

    #[error("Failed to deserialize state: {0}")]
    Deserialize(String),
}
