use serde_json::Value;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum Error {
#[error("missing API key: pass one to ScrapeBadger::new or set SCRAPEBADGER_API_KEY")]
MissingApiKey,
#[error("invalid URL: {0}")]
InvalidUrl(String),
#[error("http transport error: {0}")]
Transport(#[from] reqwest::Error),
#[error("unauthorized (401): {message}")]
Unauthorized { message: String },
#[error("payment required (402): {message}")]
PaymentRequired { message: String },
#[error("rate limited (429){}", match retry_after { Some(s) => format!(", retry after {s}s"), None => String::new() })]
RateLimited {
retry_after: Option<u64>,
message: String,
},
#[error("validation error (422): {message}")]
Validation {
message: String,
detail: Value,
},
#[error("api error (status {status}): {message}")]
Api {
status: u16,
message: String,
body: Value,
},
#[error("failed to decode response: {0}")]
Decode(String),
#[cfg(feature = "stream")]
#[error("websocket error: {0}")]
WebSocket(String),
}