#![allow(unused_assignments, reason = "these unused fields are useful in debug printing")]
#[derive(Clone, Debug, Eq, PartialEq, thiserror::Error, miette::Diagnostic)]
#[non_exhaustive]
pub enum Error {
#[diagnostic(
code(google_maps::places_new::mutually_exclusive_location_fields),
severity(Error),
help(
"use either \"location_bias\" OR \"location_restriction\", not both. \
Bias influences ranking while restriction hard-limits results"
)
)]
#[error("cannot set both location bias and location restriction")]
MutuallyExclusiveLocationFields {
#[source_code]
debug: String,
#[label("both fields were set, but only one is allowed")]
span: (usize, usize),
},
#[diagnostic(
code(google_maps::places_new::invalid_place_type_for_filter),
severity(Error),
help(
"Use a Table A place type for filtering. Table B types like \"geocode\" or \
\"political\" can only appear in responses, not in filters. See \
https://developers.google.com/maps/documentation/places/web-service/place-types"
)
)]
#[error("place type {place_type:?} is from Table B and cannot be used for filtering")]
InvalidPlaceTypeForFilter {
place_type: String,
#[source_code]
debug: String,
#[label("Table B place type cannot be used in includedType parameter")]
span: (usize, usize),
},
#[diagnostic(
code(google_maps::places_new::empty_field_mask),
severity(Error),
help(
"Specify at least one field in the field mask. Use FieldMask::All for all fields, \
or FieldMask::Specific with fields like Field::PlacesDisplayName, \
Field::PlacesLocation, etc."
)
)]
#[error("field mask cannot be empty, specify at least one field to return")]
EmptyFieldMask {
#[source_code]
debug: String,
#[label("field mask was specified but contains no fields")]
span: (usize, usize),
},
#[diagnostic(
code(google_maps::places_new::no_next_page_available),
severity(Error),
help(
"check if response.next_page_token.is_some() before calling next_text_search(). \
The previous response was the last page of results"
)
)]
#[error("no next page available - the previous response was the last page of results")]
NoNextPageAvailable {
#[source_code]
debug: String,
#[label("attempted to get next page but no token was available")]
span: (usize, usize),
},
}
impl std::convert::From<Error> for crate::Error {
fn from(error: Error) -> Self {
Self::PlacesNew { source: error.into() }
}
}
impl crate::traits::ClassifiableError<'_, Self> for Error {
fn classify(&self) -> crate::ClassifiedError<'_, Self> {
crate::ClassifiedError::Permanent(self)
}
}