// src/error.rs
//
// Typed error for the public qrush API. Consumers can match on the variant
// (connection vs serialization vs configuration) instead of inspecting an
// opaque `anyhow::Error` string. `QrushError` implements `std::error::Error`,
// so it still converts into `anyhow::Error` via `?` in callers that use anyhow.

use thiserror::Error;

/// Errors returned by qrush's public API.
#[derive(Debug, Error)]
pub enum QrushError {
    /// The underlying Redis operation failed.
    #[error("redis error: {0}")]
    Redis(#[from] redis::RedisError),

    /// The job payload could not be serialized or deserialized.
    #[error("serialization error: {0}")]
    Serialization(#[from] serde_json::Error),

    /// qrush was used before it was configured (e.g. Redis URL not set).
    #[error("configuration error: {0}")]
    Config(String),
}

/// Convenience alias for `Result<T, QrushError>`.
pub type QrushResult<T> = Result<T, QrushError>;
