summaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 1ee2b94..13b42a0 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -28,6 +28,7 @@ use std::io::Cursor;
use failure::err_msg;
use failure::Error;
+use failure::ResultExt;
use failure::Fallible as Result;
use clap::ArgMatches;
use filters::filter::Filter;
@@ -91,7 +92,7 @@ fn deserialize_package_list(s: String, filepath: &str) -> Result<Vec<ComparePack
}
}
-fn main() -> Result<()> {
+fn app() -> Result<()> {
let app = cli::build_cli().get_matches();
initialize_logging(&app)?;
let config : Configuration = {
@@ -110,7 +111,9 @@ fn main() -> Result<()> {
let buffer = std::fs::read_to_string(path).map_err(Error::from)?;
trace!("Config read into memory");
- toml::de::from_str(&buffer).map_err(Error::from)
+ toml::de::from_str(&buffer)
+ .map_err(Error::from)
+ .context("Configuration file parsing")
}?;
trace!("Config deserialized");
@@ -210,3 +213,14 @@ fn main() -> Result<()> {
Ok(())
}
+
+fn print_error(e: Error) {
+ error!("Error: {}", e);
+ e.iter_causes().for_each(|cause| {
+ error!("Caused by: {}", cause)
+ });
+}
+
+fn main() {
+ let _ = app().map_err(print_error);
+}