#![allow(unused_assignments, reason = "these unused fields are useful in debug printing")]
use miette::SourceSpan;
#[derive(Clone, Debug, Eq, PartialEq, thiserror::Error, miette::Diagnostic)]
#[non_exhaustive]
pub enum Error {
#[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: SourceSpan,
},
#[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: SourceSpan,
},
#[error("Place type '{place_type}' appears in both included_types and excluded_types")]
#[diagnostic(
code(google_maps::nearby_search::conflicting_place_types),
help("Remove '{place_type}' from either included_types or excluded_types")
)]
ConflictingPlaceTypes {
place_type: String,
#[source_code]
debug: String,
#[label("type appears in both lists")]
span: SourceSpan,
},
#[error("Place type '{place_type}' appears in both included_primary_types and excluded_primary_types")]
#[diagnostic(
code(google_maps::nearby_search::conflicting_primary_place_types),
help("Remove '{place_type}' from either included_primary_types or excluded_primary_types")
)]
ConflictingPrimaryPlaceTypes {
place_type: String,
#[source_code]
debug: String,
#[label("primary type appears in both lists")]
span: SourceSpan,
},
#[error("Nearby Search only supports circular location restrictions")]
UnsupportedLocationRestriction {
restriction_type: String,
#[source_code]
debug: String,
#[label("this restriction type is not supported")]
span: SourceSpan,
},
}
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)
}
}