#[cfg(feature = "cog")]
use crate::tiles::cog::CogError;
#[cfg(feature = "unstable-duckdb")]
use crate::tiles::duckdb::DuckDBError;
#[cfg(feature = "processing")]
use crate::tiles::hillshade::HillshadeError;
#[cfg(feature = "mbtiles")]
use crate::tiles::mbtiles::MbtilesError;
#[cfg(feature = "passthrough")]
use crate::tiles::passthrough::PassthroughError;
#[cfg(feature = "pmtiles")]
use crate::tiles::pmtiles::PmtilesError;
#[cfg(feature = "postgres")]
use crate::tiles::postgres::PostgresError;
#[non_exhaustive]
#[derive(thiserror::Error, Debug)]
pub enum MartinCoreError {
#[cfg(feature = "mbtiles")]
#[error(transparent)]
MbtilesError(#[from] MbtilesError),
#[cfg(feature = "postgres")]
#[error(transparent)]
PostgresError(#[from] PostgresError),
#[cfg(feature = "unstable-duckdb")]
#[error(transparent)]
DuckDBError(#[from] DuckDBError),
#[cfg(feature = "pmtiles")]
#[error(transparent)]
PmtilesError(#[from] PmtilesError),
#[cfg(feature = "passthrough")]
#[error(transparent)]
PassthroughError(#[from] PassthroughError),
#[cfg(feature = "cog")]
#[error(transparent)]
CogError(#[from] CogError),
#[cfg(feature = "processing")]
#[error(transparent)]
HillshadeError(#[from] HillshadeError),
#[error("Source was modified and needs to be reloaded")]
SourceNeedsReload,
#[cfg(feature = "processing")]
#[error(transparent)]
GeoJsonError(#[from] super::geojson::GeoJsonError),
#[error(transparent)]
OtherError(#[from] Box<dyn std::error::Error + Send + Sync>),
}
pub type MartinCoreResult<T> = Result<T, MartinCoreError>;
impl crate::Classify for MartinCoreError {
fn kind(&self) -> crate::ErrorKind {
match self {
#[cfg(feature = "mbtiles")]
Self::MbtilesError(e) => e.kind(),
#[cfg(feature = "postgres")]
Self::PostgresError(e) => e.kind(),
#[cfg(feature = "unstable-duckdb")]
Self::DuckDBError(e) => e.kind(),
#[cfg(feature = "pmtiles")]
Self::PmtilesError(e) => e.kind(),
#[cfg(feature = "passthrough")]
Self::PassthroughError(e) => e.kind(),
#[cfg(feature = "cog")]
Self::CogError(e) => e.kind(),
#[cfg(feature = "processing")]
Self::GeoJsonError(e) => e.kind(),
#[cfg(feature = "processing")]
Self::HillshadeError(e) => e.kind(),
Self::SourceNeedsReload | Self::OtherError(_) => crate::ErrorKind::Internal,
}
}
}