use crate::Search;
use chrono::{DateTime, FixedOffset};
use serde_json::{Map, Value};
use thiserror::Error;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum Error {
#[error("cannot convert queries to strings")]
CannotConvertQueryToString(Map<String, Value>),
#[error("cannot convert cql2-json to strings")]
CannotConvertCql2JsonToString(Map<String, Value>),
#[error(transparent)]
ChronoParse(#[from] chrono::ParseError),
#[error(transparent)]
GeoJson(#[from] geojson::Error),
#[error("empty datetime interval")]
EmptyDatetimeInterval,
#[error("feature not enabled: {0}")]
FeatureNotEnabled(&'static str),
#[error("invalid bbox ({0:?}): {1}")]
InvalidBbox(Vec<f64>, &'static str),
#[error(transparent)]
#[cfg(feature = "client")]
InvalidHeaderName(#[from] http::header::InvalidHeaderName),
#[error(transparent)]
#[cfg(feature = "client")]
InvalidHeaderValue(#[from] http::header::InvalidHeaderValue),
#[error(transparent)]
#[cfg(feature = "client")]
InvalidMethod(#[from] http::method::InvalidMethod),
#[error(transparent)]
#[cfg(feature = "client")]
Io(#[from] std::io::Error),
#[error(transparent)]
#[cfg(feature = "client")]
Join(#[from] tokio::task::JoinError),
#[error(transparent)]
ParseIntError(#[from] std::num::ParseIntError),
#[error(transparent)]
ParseFloatError(#[from] std::num::ParseFloatError),
#[error(transparent)]
#[cfg(feature = "client")]
Reqwest(#[from] reqwest::Error),
#[error("search has bbox and intersects")]
SearchHasBboxAndIntersects(Search),
#[error(transparent)]
SerdeJson(#[from] serde_json::Error),
#[error(transparent)]
SerdeUrlencodedSer(#[from] serde_urlencoded::ser::Error),
#[error(transparent)]
Stac(#[from] stac::Error),
#[error("start ({0}) is after end ({1})")]
StartIsAfterEnd(DateTime<FixedOffset>, DateTime<FixedOffset>),
#[error(transparent)]
TryFromInt(#[from] std::num::TryFromIntError),
#[error(transparent)]
UrlParse(#[from] url::ParseError),
#[error("this functionality is not yet implemented: {0}")]
Unimplemented(&'static str),
}