summaryrefslogtreecommitdiffstats
path: root/bin/core
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2019-04-22 12:59:58 +0200
committerMatthias Beyer <mail@beyermatthias.de>2019-04-22 14:40:07 +0200
commit0d5229be107227a18676e71620668fe36eaf135e (patch)
tree6917a520945a9e2495edec980a4371031ee6e4cd /bin/core
parent94246613934708ec195d7e45115e7e9ab56006cd (diff)
Refactor error handling
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'bin/core')
-rw-r--r--bin/core/imag-ref/src/main.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/bin/core/imag-ref/src/main.rs b/bin/core/imag-ref/src/main.rs
index 5aaec5ed..adb8d1e2 100644
--- a/bin/core/imag-ref/src/main.rs
+++ b/bin/core/imag-ref/src/main.rs
@@ -36,6 +36,7 @@
#[macro_use] extern crate log;
extern crate clap;
+extern crate failure;
extern crate libimagstore;
#[macro_use] extern crate libimagrt;
@@ -50,6 +51,8 @@ use ui::build_ui;
use std::process::exit;
use std::io::Write;
+use failure::Error;
+
use libimagerror::trace::MapErrTrace;
use libimagerror::exit::ExitUnwrap;
use libimagrt::setup::generate_runtime_setup;
@@ -106,12 +109,10 @@ fn deref(rt: &Runtime) {
}
.map_err_trace_exit_unwrap()
.to_str()
- .ok_or_else(|| {
- error!("Could not transform path into string!");
- exit(1)
- })
- .map(|s| writeln!(outlock, "{}", s))
- .ok(); // safe here because we exited already in the error case
+ .ok_or_else(|| ::libimagerror::errors::ErrorMsg::UTF8Error)
+ .map_err(Error::from)
+ .and_then(|s| writeln!(outlock, "{}", s).map_err(Error::from))
+ .map_err_trace_exit_unwrap();
let _ = rt.report_touched(&id).unwrap_or_exit();
},