//! Error types for FlareDB.

use thiserror::Error;

/// Main error type for FlareDB operations.
#[derive(Error, Debug)]
pub enum FlareError {
    #[error("Storage error: {0}")]
    Storage(String),

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

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

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

    #[error("Region not found: {0}")]
    RegionNotFound(u64),

    #[error("Not leader for region {region_id}")]
    NotLeader { region_id: u64 },

    #[error("Invalid operation: {0}")]
    InvalidOperation(String),

    #[error("Internal error: {0}")]
    Internal(#[from] anyhow::Error),
}

/// Result type alias for FlareDB operations.
pub type FlareResult<T> = std::result::Result<T, FlareError>;
