1use geolith_dataset_builder::error::DatasetError;
4use geolith_routing_builder::error::BuildError;
5use geolith_search_builder::SearchError;
6use geolith_tiles_builder::TilesError;
7
8use geolith::error::GeolithError;
9
10#[derive(Debug, thiserror::Error)]
18#[non_exhaustive]
19pub enum CliError {
20 #[error(transparent)]
22 Tiles(Box<TilesError>),
23
24 #[error(transparent)]
26 Dataset(Box<DatasetError>),
27
28 #[error(transparent)]
30 Search(Box<SearchError>),
31
32 #[error(transparent)]
34 Routing(Box<BuildError>),
35
36 #[error(transparent)]
38 Geolith(Box<GeolithError>),
39
40 #[error(transparent)]
42 Usage(#[from] clap::Error),
43
44 #[error("unsupported --output-format '{format}': expected tiles, geocoding or routing")]
46 UnsupportedFormat {
47 format: String,
49 },
50
51 #[error("--output-format routing needs --osm-pbf: the graph is built from OSM")]
53 RoutingNeedsOsmPbf,
54}
55
56macro_rules! boxed_from {
57 ($($error:ty => $variant:ident),+ $(,)?) => {$(
58 impl From<$error> for CliError {
59 fn from(error: $error) -> Self {
60 Self::$variant(Box::new(error))
61 }
62 }
63 )+};
64}
65
66boxed_from! {
67 TilesError => Tiles,
68 DatasetError => Dataset,
69 SearchError => Search,
70 BuildError => Routing,
71 GeolithError => Geolith,
72}