imag-log: Move from error-chain to failure
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
parent
62eb711409
commit
d7eda6c451
2 changed files with 12 additions and 6 deletions
|
@ -24,9 +24,10 @@ maintenance = { status = "actively-developed" }
|
||||||
[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" }
|
||||||
is-match = "0.1"
|
is-match = "0.1"
|
||||||
itertools = "0.7"
|
itertools = "0.7"
|
||||||
|
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" }
|
||||||
|
|
|
@ -38,6 +38,7 @@ extern crate clap;
|
||||||
extern crate toml;
|
extern crate toml;
|
||||||
extern crate toml_query;
|
extern crate toml_query;
|
||||||
extern crate itertools;
|
extern crate itertools;
|
||||||
|
extern crate failure;
|
||||||
|
|
||||||
extern crate libimaglog;
|
extern crate libimaglog;
|
||||||
#[macro_use] extern crate libimagrt;
|
#[macro_use] extern crate libimagrt;
|
||||||
|
@ -47,6 +48,9 @@ extern crate libimagdiary;
|
||||||
|
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
|
use failure::Error;
|
||||||
|
use failure::err_msg;
|
||||||
|
|
||||||
use libimagrt::runtime::Runtime;
|
use libimagrt::runtime::Runtime;
|
||||||
use libimagrt::setup::generate_runtime_setup;
|
use libimagrt::setup::generate_runtime_setup;
|
||||||
use libimagerror::trace::MapErrTrace;
|
use libimagerror::trace::MapErrTrace;
|
||||||
|
@ -55,7 +59,6 @@ use libimagerror::exit::ExitUnwrap;
|
||||||
use libimagerror::iter::TraceIterator;
|
use libimagerror::iter::TraceIterator;
|
||||||
use libimagdiary::diary::Diary;
|
use libimagdiary::diary::Diary;
|
||||||
use libimaglog::log::Log;
|
use libimaglog::log::Log;
|
||||||
use libimaglog::error::LogError as LE;
|
|
||||||
use libimagstore::iter::get::StoreIdGetIteratorExtension;
|
use libimagstore::iter::get::StoreIdGetIteratorExtension;
|
||||||
|
|
||||||
mod ui;
|
mod ui;
|
||||||
|
@ -175,16 +178,17 @@ fn get_diary_name(rt: &Runtime) -> String {
|
||||||
|
|
||||||
let cfg = rt
|
let cfg = rt
|
||||||
.config()
|
.config()
|
||||||
.ok_or(LE::from("Configuration not present, cannot continue"))
|
.ok_or_else(|| Error::from(err_msg("Configuration not present, cannot continue")))
|
||||||
.map_err_trace_exit_unwrap(1);
|
.map_err_trace_exit_unwrap(1);
|
||||||
|
|
||||||
let logs = cfg
|
let logs = cfg
|
||||||
.read("log.logs")
|
.read("log.logs")
|
||||||
|
.map_err(Error::from)
|
||||||
.map_err_trace_exit_unwrap(1)
|
.map_err_trace_exit_unwrap(1)
|
||||||
.ok_or(LE::from("Configuration missing: 'log.logs'"))
|
.ok_or_else(|| Error::from(err_msg("Configuration missing: 'log.logs'")))
|
||||||
.map_err_trace_exit_unwrap(1)
|
.map_err_trace_exit_unwrap(1)
|
||||||
.as_array()
|
.as_array()
|
||||||
.ok_or(LE::from("Configuration 'log.logs' is not an Array"))
|
.ok_or_else(|| Error::from(err_msg("Configuration 'log.logs' is not an Array")))
|
||||||
.map_err_trace_exit_unwrap(1);
|
.map_err_trace_exit_unwrap(1);
|
||||||
|
|
||||||
if !logs.iter().all(|e| is_match!(e, &Value::String(_))) {
|
if !logs.iter().all(|e| is_match!(e, &Value::String(_))) {
|
||||||
|
@ -201,8 +205,9 @@ fn get_diary_name(rt: &Runtime) -> String {
|
||||||
|
|
||||||
let current_log = cfg
|
let current_log = cfg
|
||||||
.read_string("log.default")
|
.read_string("log.default")
|
||||||
|
.map_err(Error::from)
|
||||||
.map_err_trace_exit_unwrap(1)
|
.map_err_trace_exit_unwrap(1)
|
||||||
.ok_or(LE::from("Configuration missing: 'log.default'"))
|
.ok_or_else(|| Error::from(err_msg("Configuration missing: 'log.default'")))
|
||||||
.map_err_trace_exit_unwrap(1);
|
.map_err_trace_exit_unwrap(1);
|
||||||
|
|
||||||
if !logs.contains(¤t_log) {
|
if !logs.contains(¤t_log) {
|
||||||
|
|
Loading…
Reference in a new issue