imag-diagnostics: Move from error-chain to failure
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
parent
279751b99c
commit
8114c5976c
2 changed files with 10 additions and 5 deletions
|
@ -18,8 +18,9 @@ build = "../../../build.rs"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
toml = "0.4"
|
toml = "0.4"
|
||||||
toml-query = "0.7"
|
toml-query = { git = "https://github.com/matthiasbeyer/toml-query", branch = "failure" }
|
||||||
indicatif = "0.9"
|
indicatif = "0.9"
|
||||||
|
failure = "0.1"
|
||||||
|
|
||||||
libimagstore = { version = "0.9.0", path = "../../../lib/core/libimagstore" }
|
libimagstore = { version = "0.9.0", path = "../../../lib/core/libimagstore" }
|
||||||
libimagrt = { version = "0.9.0", path = "../../../lib/core/libimagrt" }
|
libimagrt = { version = "0.9.0", path = "../../../lib/core/libimagrt" }
|
||||||
|
|
|
@ -36,6 +36,7 @@ extern crate clap;
|
||||||
extern crate toml;
|
extern crate toml;
|
||||||
extern crate toml_query;
|
extern crate toml_query;
|
||||||
extern crate indicatif;
|
extern crate indicatif;
|
||||||
|
extern crate failure;
|
||||||
#[macro_use] extern crate log;
|
#[macro_use] extern crate log;
|
||||||
|
|
||||||
#[macro_use] extern crate libimagrt;
|
#[macro_use] extern crate libimagrt;
|
||||||
|
@ -52,12 +53,14 @@ use libimagerror::io::ToExitCode;
|
||||||
use libimagerror::exit::ExitUnwrap;
|
use libimagerror::exit::ExitUnwrap;
|
||||||
use libimagstore::store::FileLockEntry;
|
use libimagstore::store::FileLockEntry;
|
||||||
use libimagstore::storeid::StoreId;
|
use libimagstore::storeid::StoreId;
|
||||||
use libimagstore::error::StoreError as Error;
|
|
||||||
use libimagentrylink::internal::*;
|
use libimagentrylink::internal::*;
|
||||||
|
|
||||||
use toml::Value;
|
use toml::Value;
|
||||||
use toml_query::read::TomlValueReadExt;
|
use toml_query::read::TomlValueReadExt;
|
||||||
use indicatif::{ProgressBar, ProgressStyle};
|
use indicatif::{ProgressBar, ProgressStyle};
|
||||||
|
use failure::Fallible as Result;
|
||||||
|
use failure::Error;
|
||||||
|
use failure::err_msg;
|
||||||
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
|
@ -76,7 +79,7 @@ struct Diagnostic {
|
||||||
|
|
||||||
impl 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 {
|
Ok(Diagnostic {
|
||||||
id: entry.get_location().clone(),
|
id: entry.get_location().clone(),
|
||||||
entry_store_version: entry
|
entry_store_version: entry
|
||||||
|
@ -142,7 +145,7 @@ fn main() {
|
||||||
.into_get_iter()
|
.into_get_iter()
|
||||||
.map(|e| {
|
.map(|e| {
|
||||||
e.map_err_trace_exit_unwrap(1)
|
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_err_trace_exit_unwrap(1)
|
||||||
})
|
})
|
||||||
.map(|e| {
|
.map(|e| {
|
||||||
|
@ -163,7 +166,7 @@ fn main() {
|
||||||
|
|
||||||
diag
|
diag
|
||||||
})
|
})
|
||||||
.collect::<Result<Vec<_>, _>>()
|
.collect::<Result<Vec<_>>>()
|
||||||
.map_err_trace_exit_unwrap(1);
|
.map_err_trace_exit_unwrap(1);
|
||||||
|
|
||||||
spinner.finish();
|
spinner.finish();
|
||||||
|
@ -265,6 +268,7 @@ fn main() {
|
||||||
fn get_config(rt: &Runtime, s: &'static str) -> Option<String> {
|
fn get_config(rt: &Runtime, s: &'static str) -> Option<String> {
|
||||||
rt.config().and_then(|cfg| {
|
rt.config().and_then(|cfg| {
|
||||||
cfg.read(s)
|
cfg.read(s)
|
||||||
|
.map_err(Error::from)
|
||||||
.map_err_trace_exit_unwrap(1)
|
.map_err_trace_exit_unwrap(1)
|
||||||
.map(|opt| match opt {
|
.map(|opt| match opt {
|
||||||
&Value::String(ref s) => s.to_owned(),
|
&Value::String(ref s) => s.to_owned(),
|
||||||
|
|
Loading…
Reference in a new issue