geolith_search_builder/
error.rs1use std::path::PathBuf;
4
5use geolith::error::GeolithError;
6
7#[derive(Debug, thiserror::Error)]
12#[non_exhaustive]
13pub enum SearchError {
14 #[error(transparent)]
16 Geolith(#[from] GeolithError),
17
18 #[error("i/o error")]
20 Io(#[from] std::io::Error),
21
22 #[error("invalid --bbox")]
24 InvalidBbox(#[source] GeolithError),
25
26 #[error(
28 "the geocoding build area touches Survey of India land (the whole world without \
29 --bbox): pass --india-outline <Survey of India GeoJSON>"
30 )]
31 IndiaOutlineRequired,
32
33 #[error("unknown geocoding format {format:?}: use glx, pg-copy, photon or pelias")]
35 UnknownFormat {
36 format: String,
38 },
39
40 #[error("OSM PBF read error")]
42 OsmPbf(#[from] osmpbf::Error),
43
44 #[error("failed to read {}", path.display())]
46 ReadOsmPbf {
47 path: PathBuf,
49 #[source]
51 source: osmpbf::Error,
52 },
53
54 #[error("failed to create geocoding output: {}", path.display())]
56 CreateOutput {
57 path: PathBuf,
59 #[source]
61 source: std::io::Error,
62 },
63
64 #[error("failed to create buildings output: {}", path.display())]
66 CreateBuildingsOutput {
67 path: PathBuf,
69 #[source]
71 source: std::io::Error,
72 },
73
74 #[error("failed to create {}", path.display())]
76 CreateScratch {
77 path: PathBuf,
79 #[source]
81 source: std::io::Error,
82 },
83
84 #[error("failed to create the temporary folder {} (--tmpdir)", path.display())]
87 CreateTmpDir {
88 path: PathBuf,
90 #[source]
92 source: std::io::Error,
93 },
94
95 #[error("failed to create dedup buckets in {}", dir.display())]
97 CreateDedupBuckets {
98 dir: PathBuf,
100 #[source]
102 source: std::io::Error,
103 },
104
105 #[error("failed to start the OSM dedup")]
107 StartDedup(#[source] std::io::Error),
108
109 #[error("failed to read {}", path.display())]
111 ReadSource {
112 path: PathBuf,
114 #[source]
116 source: GeolithError,
117 },
118
119 #[error("failed to write geocoding record")]
121 WriteRecord(#[source] std::io::Error),
122
123 #[error("failed to write building document")]
125 WriteBuildingDocument(#[source] std::io::Error),
126
127 #[error("failed to initialise pg-copy writer")]
129 InitPgCopy(#[source] std::io::Error),
130
131 #[error("failed to write the glx file")]
133 WriteGlx(#[source] std::io::Error),
134
135 #[error("failed to add the credit to {}", path.display())]
137 AddCredit {
138 path: PathBuf,
140 #[source]
142 source: std::io::Error,
143 },
144
145 #[error("the output name {name:?} is not a SQL table name: use letters, digits, '_' and '-'")]
149 InvalidTableName {
150 name: String,
152 },
153
154 #[error("failed to write geocoding DDL: {}", path.display())]
156 WriteDdl {
157 path: PathBuf,
159 #[source]
161 source: std::io::Error,
162 },
163
164 #[error("failed to open {}", path.display())]
166 OpenImportance {
167 path: PathBuf,
169 #[source]
171 source: std::io::Error,
172 },
173
174 #[error("failed to read {}", path.display())]
176 ReadImportance {
177 path: PathBuf,
179 #[source]
181 source: std::io::Error,
182 },
183}
184
185pub type Result<T, E = SearchError> = std::result::Result<T, E>;