use std::time::Duration;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("HTTP 401 {url}: {body}")]
Unauthorized { url: String, body: String },
#[error("HTTP {status} {url}: {body}")]
Http {
status: u16,
url: String,
body: String,
},
#[error("network error: {0}")]
Network(#[from] reqwest::Error),
#[error("decoding response from {url}: {source}")]
Decode {
url: String,
#[source]
source: serde_json::Error,
},
#[error("OAuth state mismatch — got {actual:?}, expected {expected:?}")]
StateMismatch {
actual: Option<String>,
expected: String,
},
#[error("OAuth flow cancelled in browser: {0}")]
Cancelled(String),
#[error("OAuth handshake timed out after {0:?}")]
Timeout(Duration),
#[error("bad request: {0}")]
BadRequest(String),
#[error("I/O: {0}")]
Io(#[from] std::io::Error),
}
pub type Result<T> = std::result::Result<T, Error>;