use thiserror::Error;
#[derive(Debug, Error)]
pub enum HttpError {
#[error("Connection error: {0}")]
Connection(#[source] Box<dyn std::error::Error + Send + Sync>),
#[error("Request timed out")]
Timeout,
#[error("Invalid URL: {0}")]
InvalidUrl(String),
}
#[derive(Debug, Error)]
pub enum RetryableError {
#[error(transparent)]
Http(#[from] HttpError),
#[error("HTTP {}: {}", status.as_u16(), body.as_deref().unwrap_or("<no body>"))]
NonSuccessStatus {
status: http::StatusCode,
body: Option<String>,
},
#[error("Template error: {0}")]
Template(String),
}
#[derive(Debug, Error)]
pub enum WebhookError {
#[error(transparent)]
Retryable(#[from] RetryableError),
#[error("Failed after {attempts} attempts")]
MaxRetriesExceeded {
attempts: u32,
#[source]
last_error: RetryableError,
},
}