use crate::Version;
use thiserror::Error;
#[derive(Error, Debug)]
#[non_exhaustive]
pub enum Error {
#[error("cannot convert queries to strings")]
CannotConvertQueryToString(serde_json::Map<String, serde_json::Value>),
#[error("cannot convert cql2-json to strings")]
CannotConvertCql2JsonToString(serde_json::Map<String, serde_json::Value>),
#[error(transparent)]
ChronoParse(#[from] chrono::ParseError),
#[error(transparent)]
Cql2(#[from] Box<cql2::Error>),
#[error(transparent)]
Geojson(#[from] Box<geojson::Error>),
#[error("empty datetime interval")]
EmptyDatetimeInterval,
#[error("feature not enabled: {0}")]
FeatureNotEnabled(&'static str),
#[error("incorrect type: expected={expected}, actual={actual}")]
IncorrectType {
actual: String,
expected: String,
},
#[error("invalid attribute name: {0}")]
InvalidAttribute(String),
#[error("invalid bbox ({0:?}): {1}")]
InvalidBbox(Vec<f64>, &'static str),
#[error("invalid datetime: {0}")]
InvalidDatetime(String),
#[error("invalid file path: {0}")]
InvalidFilePath(String),
#[error(transparent)]
Io(#[from] std::io::Error),
#[error("no \"{0}\" field in the JSON object")]
MissingField(&'static str),
#[error("no href")]
NoHref,
#[error("no items")]
NoItems,
#[error("json value is not an object")]
NotAnObject(serde_json::Value),
#[error(transparent)]
ParseIntError(#[from] std::num::ParseIntError),
#[error(transparent)]
ParseFloatError(#[from] std::num::ParseFloatError),
#[error("search has bbox and intersects")]
SearchHasBboxAndIntersects(Box<crate::api::Search>),
#[error(transparent)]
SerdeJson(#[from] serde_json::Error),
#[error(transparent)]
SerdeUrlencodedSer(#[from] serde_urlencoded::ser::Error),
#[error("start ({0}) is after end ({1})")]
StartIsAfterEnd(
chrono::DateTime<chrono::FixedOffset>,
chrono::DateTime<chrono::FixedOffset>,
),
#[error(transparent)]
TryFromInt(#[from] std::num::TryFromIntError),
#[error("unknown \"type\": {0}")]
UnknownType(String),
#[error("this functionality is not yet implemented: {0}")]
Unimplemented(&'static str),
#[error("unsupported geoparquet type")]
UnsupportedGeoparquetType,
#[error("unsupported migration: {0} to {1}")]
UnsupportedMigration(Version, Version),
#[error(transparent)]
UrlParse(#[from] url::ParseError),
#[error(transparent)]
#[cfg(feature = "geoarrow")]
Arrow(#[from] arrow_schema::ArrowError),
#[cfg(feature = "geoarrow")]
#[error("Arrow schema mismatch")]
ArrowSchemaMismatch,
#[error(transparent)]
#[cfg(feature = "geoarrow")]
GeoArrow(#[from] geoarrow_schema::error::GeoArrowError),
#[error(transparent)]
#[cfg(feature = "geoarrow")]
Wkb(#[from] wkb::error::WkbError),
#[error("no geoparquet metadata")]
#[cfg(feature = "geoparquet")]
MissingGeoparquetMetadata,
#[error(transparent)]
#[cfg(feature = "geoparquet")]
Parquet(#[from] parquet::errors::ParquetError),
#[error("invalid year: {0}")]
InvalidYear(i32),
#[error("unrecognized date format: {0}")]
UnrecognizedDateFormat(String),
}