#[cfg(feature = "unstable-cog")]
use super::cog::CogError;
#[cfg(feature = "unstable-duckdb")]
use super::duckdb::DuckDBError;
#[cfg(feature = "processing")]
use super::hillshade::HillshadeError;
#[cfg(feature = "mbtiles")]
use super::mbtiles::MbtilesError;
#[cfg(feature = "passthrough")]
use super::passthrough::PassthroughError;
#[cfg(feature = "pmtiles")]
use super::pmtiles::PmtilesError;
#[cfg(feature = "postgres")]
use super::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 = "unstable-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 = "unstable-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,
}
}
}