use std::path::PathBuf;
use geolith::error::GeolithError;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum SearchError {
#[error(transparent)]
Geolith(#[from] GeolithError),
#[error("i/o error")]
Io(#[from] std::io::Error),
#[error("invalid --bbox")]
InvalidBbox(#[source] GeolithError),
#[error(
"the geocoding build area touches Survey of India land (the whole world without \
--bbox): pass --india-outline <Survey of India GeoJSON>"
)]
IndiaOutlineRequired,
#[error("unknown geocoding format {format:?}: use glx, pg-copy, photon or pelias")]
UnknownFormat {
format: String,
},
#[error("OSM PBF read error")]
OsmPbf(#[from] osmpbf::Error),
#[error("failed to read {}", path.display())]
ReadOsmPbf {
path: PathBuf,
#[source]
source: osmpbf::Error,
},
#[error("failed to create geocoding output: {}", path.display())]
CreateOutput {
path: PathBuf,
#[source]
source: std::io::Error,
},
#[error("failed to create buildings output: {}", path.display())]
CreateBuildingsOutput {
path: PathBuf,
#[source]
source: std::io::Error,
},
#[error("failed to create {}", path.display())]
CreateScratch {
path: PathBuf,
#[source]
source: std::io::Error,
},
#[error("failed to create the temporary folder {} (--tmpdir)", path.display())]
CreateTmpDir {
path: PathBuf,
#[source]
source: std::io::Error,
},
#[error("failed to create dedup buckets in {}", dir.display())]
CreateDedupBuckets {
dir: PathBuf,
#[source]
source: std::io::Error,
},
#[error("failed to start the OSM dedup")]
StartDedup(#[source] std::io::Error),
#[error("failed to read {}", path.display())]
ReadSource {
path: PathBuf,
#[source]
source: GeolithError,
},
#[error("failed to write geocoding record")]
WriteRecord(#[source] std::io::Error),
#[error("failed to write building document")]
WriteBuildingDocument(#[source] std::io::Error),
#[error("failed to initialise pg-copy writer")]
InitPgCopy(#[source] std::io::Error),
#[error("failed to write the glx file")]
WriteGlx(#[source] std::io::Error),
#[error("failed to add the credit to {}", path.display())]
AddCredit {
path: PathBuf,
#[source]
source: std::io::Error,
},
#[error("the output name {name:?} is not a SQL table name: use letters, digits, '_' and '-'")]
InvalidTableName {
name: String,
},
#[error("failed to write geocoding DDL: {}", path.display())]
WriteDdl {
path: PathBuf,
#[source]
source: std::io::Error,
},
#[error("failed to open {}", path.display())]
OpenImportance {
path: PathBuf,
#[source]
source: std::io::Error,
},
#[error("failed to read {}", path.display())]
ReadImportance {
path: PathBuf,
#[source]
source: std::io::Error,
},
}
pub type Result<T, E = SearchError> = std::result::Result<T, E>;