use thiserror::Error;
#[derive(Debug, Error)]
pub enum HealthchecksApiError {
#[error("invalid API key")]
InvalidApiKey,
#[error("invalid API key, make sure you're not using a read-only key")]
PossibleReadOnlyKey,
#[error("access denied")]
AccessDenied,
#[error("no check found with id: {0}")]
NoCheckFound(String),
#[error("an existing check was matched based on the \"unique\" parameter")]
ExistingCheckMatched,
#[error("the request is not well-formed, violates schema, or uses invalid field values")]
NotWellFormed,
#[error("the account's check limit has been reached")]
CheckLimitReached,
#[error("unexpected transport error: {0:?}")]
TransportError(Box<ureq::Transport>),
#[error("unexpected error: {0}")]
UnexpectedError(String),
#[error("unexpected IO error")]
Io {
#[from]
source: std::io::Error,
},
#[error("unexpected error while (de)serializing JSON response")]
Json {
#[from]
source: serde_json::Error,
},
}
#[derive(Debug, Error)]
pub enum HealthchecksConfigError {
#[error("API key must not be empty")]
EmptyApiKey,
#[error("User Agent must not be empty")]
EmptyUserAgent,
#[error("API url must not be empty")]
EmptyApiUrl,
#[error("invalid UUID: {0}")]
InvalidUuid(String),
}