use std::error;
use std::fmt::{Display, Formatter};
#[derive(Debug)]
pub enum BusinessSearchPayloadError {
BothLocationAndLatLongSet,
RadiusTooLarge(usize),
LimitTooLarge(usize),
BothOpenNowAndOpenAtSet,
}
impl error::Error for BusinessSearchPayloadError {}
impl Display for BusinessSearchPayloadError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Self::BothLocationAndLatLongSet => {
write!(f, "can either set location OR latitude/longitude, NOT both")
}
Self::RadiusTooLarge(radius) => {
write!(f, "radius must not be above 40,000 meters: {}", radius)
}
Self::LimitTooLarge(limit) => write!(f, "limit must not be over 50: {}", limit),
Self::BothOpenNowAndOpenAtSet => {
write!(f, "can only set open_now OR open_at, not both")
}
}
}
}