//! Perception module error types
//!
//! Defines errors for perception and reasoning operations.

use thiserror::Error;

/// Errors that can occur during perception operations
#[derive(Debug, Error)]
pub enum PerceptionError {
    #[error("Model not loaded: {0}")]
    ModelNotLoaded(String),

    #[error("Unsupported modality: {0}")]
    UnsupportedModality(String),

    #[error("Invalid input: {0}")]
    InvalidInput(String),

    #[error("Dimension mismatch: expected {expected}, got {got}")]
    DimensionMismatch { expected: usize, got: usize },

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

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

    #[error("Model download error: {0}")]
    ModelDownloadError(String),

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

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

    #[error("Feature not enabled: {0}")]
    FeatureNotEnabled(String),
}

/// Errors that can occur during reasoning operations
#[derive(Debug, Error)]
pub enum ReasoningError {
    #[error("API error: {status} - {message}")]
    ApiError { status: u16, message: String },

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

    #[error("Timeout: operation took longer than {timeout_secs} seconds")]
    Timeout { timeout_secs: u64 },

    #[error("Rate limited: {0}")]
    RateLimited(String),

    #[error("Invalid response: {0}")]
    InvalidResponse(String),

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

    #[error("Model not available: {0}")]
    ModelNotAvailable(String),

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

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

/// Result type for perception operations
pub type PerceptionResult<T> = Result<T, PerceptionError>;

/// Result type for reasoning operations
pub type ReasoningResult<T> = Result<T, ReasoningError>;
