use thiserror::Error;

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

#[derive(Debug, Error)]
pub enum BifrostError {
    #[error("IO error: {0}")]
    Io(#[from] std::io::Error),

    #[error("YAML parse error: {0}")]
    Yaml(#[from] serde_yaml::Error),

    #[error("JSON error: {0}")]
    Json(#[from] serde_json::Error),

    #[error("Arrow error: {0}")]
    Arrow(#[from] arrow::error::ArrowError),

    #[error("FalkorDB error: {0}")]
    Falkor(#[from] graphar_falkordb::FalkorError),

    #[error("Valkey error: {0}")]
    Valkey(#[from] redis::RedisError),

    #[error("Column '{0}' not found in table batch")]
    ColumnNotFound(String),

    #[error("transform produces two output columns named '{0}' (endpoint/property name collision)")]
    DuplicateOutputColumn(String),

    #[error("Custom transform '{0}' is not registered — call TransformRegistry::register first")]
    TransformNotRegistered(String),

    #[error("Table '{0}' has an empty pipeline")]
    EmptyPipeline(String),

    #[error("Source error: {0}")]
    Source(String),

    #[error("{0}")]
    Other(String),
}
