use thiserror::Error;
pub type AuthResult<T> = Result<T, AuthError>;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum AuthError {
#[error("missing required builder field: {0}")]
MissingField(&'static str),
#[error("OAuth error: {error}{}", .error_description.as_deref().map(|d| format!(" — {d}")).unwrap_or_default())]
OAuth {
error: String,
error_description: Option<String>,
},
#[error("authentication failed: {0}")]
Other(String),
#[error("HTTP request failed: {0}")]
Http(#[from] reqwest::Error),
#[error("serialization error: {0}")]
Serialization(#[from] serde_json::Error),
#[error("invalid URL: {0}")]
Url(#[from] url::ParseError),
}