#[derive(Clone, Debug, thiserror::Error, miette::Diagnostic)]
pub enum Error {
#[error("invalid status: `{0}`")]
#[diagnostic(
code(google_maps::time_zone::parse::invalid_status_code),
url("https://developers.google.com/maps/documentation/timezone/requests-timezone#TimeZoneStatus"),
help("valid codes are `OK`, `INVALID_REQUEST`, `OVER_DAILY_LIMIT`, \
`OVER_QUERY_LIMIT`, `REQUEST_DENIED`, `UNKNOWN_ERROR` and \
`ZERO_RESULTS`")
)]
InvalidStatusCode(String),
#[error("invalid request")]
#[diagnostic(
code(google_maps::time_zone::status::invalid_request),
url("https://developers.google.com/maps/documentation/timezone/requests-timezone#TimeZoneStatus"),
help("indicates that the request was malformed")
)]
InvalidRequest,
#[error("over daily limit")]
#[diagnostic(
code(google_maps::time_zone::status::over_daily_limit),
url("https://developers.google.com/maps/faq#over-limit-key-error"),
help("either the API key is missing or invalid, billing has not been \
enabled on your account, a self-imposed usage cap has been \
exceeded, or the provided method of payment is no longer valid \
(for example, a credit card has expired)")
)]
OverDailyLimit,
#[error("over query limit")]
#[diagnostic(
code(google_maps::time_zone::status::over_query_limit),
url("https://developers.google.com/maps/faq#over-limit-key-error"),
help("either you have exceeded the QPS limits, billing has not been \
enabled on your account, a self-imposed usage cap has been \
exceeded or the provided method of payment is no longer valid")
)]
OverQueryLimit,
#[error("request denied")]
#[diagnostic(
code(google_maps::time_zone::status::request_denied),
url("https://developers.google.com/maps/documentation/timezone/requests-timezone#TimeZoneStatus"),
help("indicates that your request was denied")
)]
RequestDenied,
#[error("unknown error")]
#[diagnostic(
code(google_maps::time_zone::status::unknown_error),
url("https://developers.google.com/maps/documentation/timezone/requests-timezone#TimeZoneStatus"),
help("indicates that the request could not be processed due to a \
server error. The request may succeed if you try again")
)]
UnknownError,
#[error("zero results")]
#[diagnostic(
code(google_maps::time_zone::status::zero_results),
url("https://developers.google.com/maps/documentation/timezone/requests-timezone#TimeZoneStatus"),
help("indicates that no time zone data could be found for the \
specified position or time. Confirm that the request is for a \
location on land, and not over water")
)]
ZeroResults,
}
use crate::ClassifiedError;
impl crate::traits::ClassifiableError<'_, Self> for Error {
fn classify(&self) -> ClassifiedError<'_, Self> {
match self {
Self::UnknownError => ClassifiedError::Transient(self),
_ => ClassifiedError::Permanent(self),
} } }