Skip to content

Commit 5b48256

Browse files
committed
Improve error message for invalid configuration file
1 parent a332cff commit 5b48256

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/main.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ impl std::fmt::Debug for Column<'_> {
7171
}
7272
}
7373

74+
#[derive(Debug)]
7475
struct Geometry {
7576
gtype: u8,
7677
dims: u8,
@@ -110,6 +111,7 @@ fn gml_to_ewkb(cell: &RefCell<String>, coll: &[Geometry], bbox: Option<&BBox>, m
110111
}
111112

112113
for geom in coll {
114+
// println!("{:?}", geom);
113115
let code = match geom.dims {
114116
2 => 32, // Indicate EWKB where the srid follows this byte
115117
3 => 32 | 128, // Add bit to indicate the presense of Z values
@@ -223,14 +225,14 @@ fn main() -> std::io::Result<()> {
223225
bufread = Box::new(BufReader::new(File::open(&args[2])?));
224226
}
225227
else {
226-
eprintln!("usage: {} <configfile> <xmlfile>", args[0]);
228+
eprintln!("usage: {} <configfile> [xmlfile]", args[0]);
227229
return Ok(());
228230
}
229231

230232
let config = {
231233
let mut config_str = String::new();
232234
File::open(&args[1]).unwrap().read_to_string(&mut config_str).unwrap();
233-
&YamlLoader::load_from_str(&config_str).unwrap()[0]
235+
&YamlLoader::load_from_str(&config_str).unwrap_or_else(|err| { eprintln!("Syntax error in configuration file: {}", err); std::process::exit(0); })[0]
234236
};
235237

236238
let mut reader;

0 commit comments

Comments
 (0)