diff --git a/src/errors.rs b/src/errors.rs new file mode 100644 index 0000000..0c6d43c --- /dev/null +++ b/src/errors.rs @@ -0,0 +1 @@ +error_chain!{} diff --git a/src/main.rs b/src/main.rs index 46c3c3c..080b472 100644 --- a/src/main.rs +++ b/src/main.rs @@ -22,7 +22,6 @@ extern crate byteorder; #[macro_use] extern crate serde_derive; - use clap::{AppSettings, Arg, App, SubCommand}; mod commands; use self::commands::*; @@ -137,5 +136,12 @@ fn main() { "bench" => run_bench_cli, _ => panic!("Subcommand {} is unknown", subcommand) }; - run_cli(options).unwrap(); + + if let Err(ref e) = run_cli(options) { + use std::io::Write; + let stderr = &mut ::std::io::stderr(); + let errmsg = "Error writing ot stderr"; + writeln!(stderr, "{}", e).expect(errmsg); + ::std::process::exit(1); + } }