//! Error types for Aphoria.

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

/// Errors that can occur during Aphoria operations.
#[derive(Error, Debug)]
pub enum AphoriaError {
    /// Configuration file error.
    #[error("Configuration error: {0}")]
    Config(String),

    /// Configuration file not found.
    #[error("Configuration file not found: {0}")]
    ConfigNotFound(PathBuf),

    /// Invalid configuration format.
    #[error("Invalid configuration: {0}")]
    ConfigParse(#[from] toml::de::Error),

    /// Project not found.
    #[error("Project not found: {0}")]
    ProjectNotFound(PathBuf),

    /// File system error.
    #[error("File system error: {0}")]
    Io(#[from] std::io::Error),

    /// Walker error during file traversal.
    #[error("Walker error: {0}")]
    Walker(String),

    /// Extractor error during claim extraction.
    #[error("Extraction error in {extractor}: {message}")]
    Extraction {
        /// The extractor that failed.
        extractor: String,
        /// The error message.
        message: String,
    },

    /// Episteme storage error.
    #[error("Storage error: {0}")]
    Storage(String),

    /// Query error during conflict detection.
    #[error("Query error: {0}")]
    Query(String),

    /// Report generation error.
    #[error("Report error: {0}")]
    Report(String),

    /// Baseline not found.
    #[error("No baseline set. Run `aphoria baseline` first.")]
    NoBaseline,

    /// Initialization error.
    #[error("Initialization error: {0}")]
    Init(String),

    /// Acknowledgment error.
    #[error("Acknowledgment error: {0}")]
    Acknowledge(String),
}
