summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2018-10-30 18:40:53 +0100
committerMatthias Beyer <mail@beyermatthias.de>2018-10-30 18:46:29 +0100
commitd7eda6c451db81225d091c5513600fd6004d0643 (patch)
treeca5a29f1b66b8ae72eaab9a423d066ffc9cc41a7
parent62eb711409773cd2675af67c91c561a759da1acd (diff)
downloadimag-d7eda6c451db81225d091c5513600fd6004d0643.zip
imag-d7eda6c451db81225d091c5513600fd6004d0643.tar.gz
imag-log: Move from error-chain to failure
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--bin/domain/imag-log/Cargo.toml3
-rw-r--r--bin/domain/imag-log/src/main.rs15
2 files changed, 12 insertions, 6 deletions
diff --git a/bin/domain/imag-log/Cargo.toml b/bin/domain/imag-log/Cargo.toml
index 98283c1..640f098 100644
--- a/bin/domain/imag-log/Cargo.toml
+++ b/bin/domain/imag-log/Cargo.toml
@@ -24,9 +24,10 @@ maintenance = { status = "actively-developed" }
[dependencies]
log = "0.4"
toml = "0.4"
-toml-query = "0.7"
+toml-query = { git = "https://github.com/matthiasbeyer/toml-query", branch = "failure" }
is-match = "0.1"
itertools = "0.7"
+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/domain/imag-log/src/main.rs b/bin/domain/imag-log/src/main.rs
index 053f06e..56d5018 100644
--- a/bin/domain/imag-log/src/main.rs
+++ b/bin/domain/imag-log/src/main.rs
@@ -38,6 +38,7 @@ extern crate clap;
extern crate toml;
extern crate toml_query;
extern crate itertools;
+extern crate failure;
extern crate libimaglog;
#[macro_use] extern crate libimagrt;
@@ -47,6 +48,9 @@ extern crate libimagdiary;
use std::io::Write;
+use failure::Error;
+use failure::err_msg;
+
use libimagrt::runtime::Runtime;
use libimagrt::setup::generate_runtime_setup;
use libimagerror::trace::MapErrTrace;
@@ -55,7 +59,6 @@ use libimagerror::exit::ExitUnwrap;
use libimagerror::iter::TraceIterator;
use libimagdiary::diary::Diary;
use libimaglog::log::Log;
-use libimaglog::error::LogError as LE;
use libimagstore::iter::get::StoreIdGetIteratorExtension;
mod ui;
@@ -175,16 +178,17 @@ fn get_diary_name(rt: &Runtime) -> String {
let cfg = rt
.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);
let logs = cfg
.read("log.logs")
+ .map_err(Error::from)
.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)
.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);
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
.read_string("log.default")
+ .map_err(Error::from)
.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);
if !logs.contains(&current_log) {