use thiserror::Error;

#[derive(Error, Debug)]
pub enum ChannelError {
    #[error("HTTP request failed for channel '{channel}': {source}")]
    HttpError {
        channel: String,
        #[source]
        source: reqwest::Error,
    },

    #[error("Channel '{0}' not found in registry")]
    NotFound(String),

    #[error("Channel '{channel}' returned non-success status {status}: {body}")]
    ApiError {
        channel: String,
        status: u16,
        body: String,
    },

    #[error("Failed to build HTTP client: {0}")]
    HttpClientBuild(String),

    /// Raised when a `${VAR}` reference is present in config but the env var
    /// is not set and no `:-default` was provided.
    #[error("Secret reference '${{{{0}}}}' not resolved: env var not set and no default provided")]
    SecretNotFound(String),
}

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