#[derive(Clone, Debug, thiserror::Error, miette::Diagnostic)]
pub enum Error {
#[error("a `for_sampled_path_request` method cannot be used when \
`for_postional_request` has been set")]
#[diagnostic(
code(google_maps::elevation::validate::either_positional_or_sampled_path),
url(docsrs),
help("try again with only a positional request or only a sampled path \
request")
)]
EitherPositionalOrSampledPath,
#[error("invalid status: `{0}`")]
#[diagnostic(
code(google_maps::elevation::parse::invalid_status_code),
url("https://developers.google.com/maps/documentation/elevation/requests-elevation#ElevationStatus"),
help("valid codes are `OK`, `DATA_NOT_AVAILABLE`, `INVALID_REQUEST`, \
`OVER_DAILY_LIMIT`, `OVER_QUERY_LIMIT`, `REQUEST_DENIED`, and \
`UNKNOWN_ERROR`")
)]
InvalidStatusCode(String),
#[error("data not available")]
#[diagnostic(
code(google_maps::elevation::status::data_not_available),
url("https://developers.google.com/maps/documentation/elevation/requests-elevation#ElevationStatus"),
help("indicates that there's no available data for the input location")
)]
DataNotAvailable,
#[error("invalid request")]
#[diagnostic(
code(google_maps::elevation::status::invalid_request),
url("https://developers.google.com/maps/documentation/elevation/requests-elevation#ElevationStatus"),
help("indicates the API request was malformed")
)]
InvalidRequest,
#[error("over daily limit")]
#[diagnostic(
code(google_maps::elevation::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::elevation::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::elevation::status::request_denied),
url("https://developers.google.com/maps/documentation/elevation/requests-elevation#ElevationStatus"),
help("indicates that your request was denied")
)]
RequestDenied,
#[error("unknown error")]
#[diagnostic(
code(google_maps::elevation::status::unknown_error),
url("https://developers.google.com/maps/documentation/elevation/requests-elevation#ElevationStatus"),
help("indicates that the request could not be processed due to a \
server error. The request may succeed if you try again")
)]
UnknownError,
}
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),
} } }