use std::io;
use std::path::PathBuf;
#[cfg(feature = "unstable-cog")]
use martin_core::tiles::cog::CogError;
#[cfg(feature = "geojson")]
use martin_core::tiles::geojson::GeoJsonError;
#[cfg(feature = "mbtiles")]
use martin_core::tiles::mbtiles::MbtilesError;
#[cfg(feature = "passthrough")]
use martin_core::tiles::passthrough::PassthroughError;
#[cfg(feature = "pmtiles")]
use martin_core::tiles::pmtiles::PmtilesError;
#[cfg(feature = "postgres")]
use martin_core::tiles::postgres::PostgresError;
use crate::config::file::ConfigFileError;
pub type SourceBuildResult<T> = Result<T, SourceBuildError>;
#[derive(thiserror::Error, Debug)]
pub enum SourceBuildError {
#[cfg(feature = "postgres")]
#[error(transparent)]
Postgres(#[from] PostgresError),
#[cfg(feature = "pmtiles")]
#[error(transparent)]
Pmtiles(#[from] PmtilesError),
#[cfg(feature = "mbtiles")]
#[error(transparent)]
Mbtiles(#[from] MbtilesError),
#[cfg(feature = "passthrough")]
#[error(transparent)]
Passthrough(#[from] PassthroughError),
#[cfg(feature = "unstable-cog")]
#[error(transparent)]
Cog(#[from] CogError),
#[cfg(feature = "geojson")]
#[error(transparent)]
GeoJson(#[from] GeoJsonError),
#[error(transparent)]
Config(#[from] ConfigFileError),
#[error("IO error while building tile sources: {0}")]
Io(#[from] io::Error),
#[error("Source '{0}' not found in discovered sources")]
SourceNotFound(String),
#[error("Source path is not a file: {0}")]
InvalidFilePath(PathBuf),
}