//! Error types for the chaos testing framework.

use thiserror::Error;

/// Errors that can occur during chaos testing.
#[derive(Error, Debug)]
pub enum ChaosError {
    /// Storage operation failed.
    #[error("storage error: {0}")]
    Storage(#[from] stemedb_storage::error::StorageError),

    /// Merkle tree operation failed.
    #[error("merkle error: {0}")]
    Merkle(#[from] stemedb_merkle::TreeError),

    /// Node not found in cluster.
    #[error("node {0} not found in cluster")]
    NodeNotFound(usize),

    /// Cluster has not converged within timeout.
    #[error("cluster did not converge within {0:?}")]
    ConvergenceTimeout(std::time::Duration),

    /// Invalid cluster configuration.
    #[error("invalid cluster configuration: {0}")]
    InvalidConfig(String),

    /// Network operation failed.
    #[error("network error: {0}")]
    Network(String),

    /// Sync operation failed.
    #[error("sync error: {0}")]
    Sync(String),
}

/// Result type for chaos testing operations.
pub type Result<T> = std::result::Result<T, ChaosError>;
