Refactor error handling
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
parent
9424661393
commit
0d5229be10
1 changed files with 7 additions and 6 deletions
|
@ -36,6 +36,7 @@
|
||||||
|
|
||||||
#[macro_use] extern crate log;
|
#[macro_use] extern crate log;
|
||||||
extern crate clap;
|
extern crate clap;
|
||||||
|
extern crate failure;
|
||||||
|
|
||||||
extern crate libimagstore;
|
extern crate libimagstore;
|
||||||
#[macro_use] extern crate libimagrt;
|
#[macro_use] extern crate libimagrt;
|
||||||
|
@ -50,6 +51,8 @@ use ui::build_ui;
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
|
use failure::Error;
|
||||||
|
|
||||||
use libimagerror::trace::MapErrTrace;
|
use libimagerror::trace::MapErrTrace;
|
||||||
use libimagerror::exit::ExitUnwrap;
|
use libimagerror::exit::ExitUnwrap;
|
||||||
use libimagrt::setup::generate_runtime_setup;
|
use libimagrt::setup::generate_runtime_setup;
|
||||||
|
@ -106,12 +109,10 @@ fn deref(rt: &Runtime) {
|
||||||
}
|
}
|
||||||
.map_err_trace_exit_unwrap()
|
.map_err_trace_exit_unwrap()
|
||||||
.to_str()
|
.to_str()
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| ::libimagerror::errors::ErrorMsg::UTF8Error)
|
||||||
error!("Could not transform path into string!");
|
.map_err(Error::from)
|
||||||
exit(1)
|
.and_then(|s| writeln!(outlock, "{}", s).map_err(Error::from))
|
||||||
})
|
.map_err_trace_exit_unwrap();
|
||||||
.map(|s| writeln!(outlock, "{}", s))
|
|
||||||
.ok(); // safe here because we exited already in the error case
|
|
||||||
|
|
||||||
let _ = rt.report_touched(&id).unwrap_or_exit();
|
let _ = rt.report_touched(&id).unwrap_or_exit();
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue