use serde_json::Value;
use thiserror::Error;

#[derive(Debug, Error)]
pub enum RestAdapterError {
    #[error("invalid base url: {url}")]
    InvalidBaseUrl { url: String },
    #[error("invalid path parameter {key}")]
    InvalidPathParameter { key: String },
    #[error("invalid query parameter {key}")]
    InvalidQueryParameter { key: String },
    #[error("invalid header name {header}")]
    InvalidHeaderName { header: String },
    #[error("invalid header value for {header}")]
    InvalidHeaderValue { header: String },
    #[error("request failed")]
    Transport(#[from] reqwest::Error),
    #[error("sse collection window expired before stream completed")]
    WindowExpired,
    #[error("rest endpoint returned status {status}")]
    UnexpectedStatus { status: u16, body: Value },
    #[error("sse stream produced malformed event payload")]
    InvalidSseEvent,
}
