summaryrefslogtreecommitdiffstats
path: root/bin/core
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2018-10-30 18:40:52 +0100
committerMatthias Beyer <mail@beyermatthias.de>2018-10-30 18:46:29 +0100
commit8114c5976c26bb62464290778516a1425a81db21 (patch)
tree8a13c255b9c8c890eac797871b70fa5fbe058efd /bin/core
parent279751b99ca119b93b5043914c07740a74ba5255 (diff)
imag-diagnostics: Move from error-chain to failure
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'bin/core')
-rw-r--r--bin/core/imag-diagnostics/Cargo.toml3
-rw-r--r--bin/core/imag-diagnostics/src/main.rs12
2 files changed, 10 insertions, 5 deletions
diff --git a/bin/core/imag-diagnostics/Cargo.toml b/bin/core/imag-diagnostics/Cargo.toml
index 58658242..20fce9ee 100644
--- a/bin/core/imag-diagnostics/Cargo.toml
+++ b/bin/core/imag-diagnostics/Cargo.toml
@@ -18,8 +18,9 @@ build = "../../../build.rs"
[dependencies]
log = "0.4"
toml = "0.4"
-toml-query = "0.7"
+toml-query = { git = "https://github.com/matthiasbeyer/toml-query", branch = "failure" }
indicatif = "0.9"
+failure = "0.1"
libimagstore = { version = "0.9.0", path = "../../../lib/core/libimagstore" }
libimagrt = { version = "0.9.0", path = "../../../lib/core/libimagrt" }
diff --git a/bin/core/imag-diagnostics/src/main.rs b/bin/core/imag-diagnostics/src/main.rs
index d8d8482b..5c592db0 100644
--- a/bin/core/imag-diagnostics/src/main.rs
+++ b/bin/core/imag-diagnostics/src/main.rs
@@ -36,6 +36,7 @@ extern crate clap;
extern crate toml;
extern crate toml_query;
extern crate indicatif;
+extern crate failure;
#[macro_use] extern crate log;
#[macro_use] extern crate libimagrt;
@@ -52,12 +53,14 @@ use libimagerror::io::ToExitCode;
use libimagerror::exit::ExitUnwrap;
use libimagstore::store::FileLockEntry;
use libimagstore::storeid::StoreId;
-use libimagstore::error::StoreError as Error;
use libimagentrylink::internal::*;
use toml::Value;
use toml_query::read::TomlValueReadExt;
use indicatif::{ProgressBar, ProgressStyle};
+use failure::Fallible as Result;
+use failure::Error;
+use failure::err_msg;
use std::collections::BTreeMap;
@@ -76,7 +79,7 @@ struct Diagnostic {
impl Diagnostic {
- fn for_entry<'a>(entry: &FileLockEntry<'a>) -> Result<Diagnostic, ::libimagstore::error::StoreError> {
+ fn for_entry<'a>(entry: &FileLockEntry<'a>) -> Result<Diagnostic> {
Ok(Diagnostic {
id: entry.get_location().clone(),
entry_store_version: entry
@@ -142,7 +145,7 @@ fn main() {
.into_get_iter()
.map(|e| {
e.map_err_trace_exit_unwrap(1)
- .ok_or(Error::from("Unable to get entry".to_owned()))
+ .ok_or_else(|| Error::from(err_msg("Unable to get entry".to_owned())))
.map_err_trace_exit_unwrap(1)
})
.map(|e| {
@@ -163,7 +166,7 @@ fn main() {
diag
})
- .collect::<Result<Vec<_>, _>>()
+ .collect::<Result<Vec<_>>>()
.map_err_trace_exit_unwrap(1);
spinner.finish();
@@ -265,6 +268,7 @@ fn main() {
fn get_config(rt: &Runtime, s: &'static str) -> Option<String> {
rt.config().and_then(|cfg| {
cfg.read(s)
+ .map_err(Error::from)
.map_err_trace_exit_unwrap(1)
.map(|opt| match opt {
&Value::String(ref s) => s.to_owned(),