use thiserror::Error;

#[derive(Debug, Error)]
pub enum WorktreeError {
    #[error("Failed to create workspace: {0}")]
    CreationFailed(String),

    #[error("Failed to remove workspace: {0}")]
    RemovalFailed(String),

    #[error("Workspace not found: {0}")]
    NotFound(String),

    #[error("Git operation failed: {0}")]
    GitError(String),

    #[error("jj operation failed: {0}")]
    JjError(String),

    #[error("Merge conflict in: {0}")]
    MergeConflict(String),

    #[error(".ontology/ write denied in degraded git mode — affected: {0:?}")]
    OntologyWriteDenied(Vec<String>),

    #[error("Max concurrent workspaces exceeded (limit: {limit})")]
    MaxConcurrentExceeded { limit: usize },

    #[error("No VCS detected at: {0}")]
    VcsDetectionFailed(String),

    #[error("IO error: {0}")]
    IoError(#[from] std::io::Error),

    #[error("Invalid workspace state: {0}")]
    InvalidState(String),

    #[error("Timeout waiting for operation")]
    Timeout,
}

pub type Result<T> = std::result::Result<T, WorktreeError>;
