use geolith_dataset_builder::error::DatasetError;
use geolith_routing_builder::error::BuildError;
use geolith_search_builder::SearchError;
use geolith_tiles_builder::TilesError;
use geolith::error::GeolithError;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum CliError {
#[error(transparent)]
Tiles(Box<TilesError>),
#[error(transparent)]
Dataset(Box<DatasetError>),
#[error(transparent)]
Search(Box<SearchError>),
#[error(transparent)]
Routing(Box<BuildError>),
#[error(transparent)]
Geolith(Box<GeolithError>),
#[error(transparent)]
Usage(#[from] clap::Error),
#[error("unsupported --output-format '{format}': expected tiles, geocoding or routing")]
UnsupportedFormat {
format: String,
},
#[error("--output-format routing needs --osm-pbf: the graph is built from OSM")]
RoutingNeedsOsmPbf,
}
macro_rules! boxed_from {
($($error:ty => $variant:ident),+ $(,)?) => {$(
impl From<$error> for CliError {
fn from(error: $error) -> Self {
Self::$variant(Box::new(error))
}
}
)+};
}
boxed_from! {
TilesError => Tiles,
DatasetError => Dataset,
SearchError => Search,
BuildError => Routing,
GeolithError => Geolith,
}