libimaglog: Move from error-chain to failure

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
Matthias Beyer 2018-10-30 18:40:51 +01:00
parent 57f7a5a682
commit 1956099e2e
4 changed files with 7 additions and 45 deletions

View file

@ -21,8 +21,8 @@ maintenance = { status = "actively-developed" }
[dependencies] [dependencies]
toml = "0.4" toml = "0.4"
toml-query = "0.7" toml-query = { git = "https://github.com/matthiasbeyer/toml-query", branch = "failure" }
error-chain = "0.12" failure = "0.1"
libimagstore = { version = "0.9.0", path = "../../../lib/core/libimagstore" } libimagstore = { version = "0.9.0", path = "../../../lib/core/libimagstore" }
libimagerror = { version = "0.9.0", path = "../../../lib/core/libimagerror" } libimagerror = { version = "0.9.0", path = "../../../lib/core/libimagerror" }

View file

@ -1,36 +0,0 @@
//
// imag - the personal information management suite for the commandline
// Copyright (C) 2015-2018 Matthias Beyer <mail@beyermatthias.de> and contributors
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; version
// 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
error_chain! {
types {
LogError, LogErrorKind, ResultExt, Result;
}
foreign_links {
TomlQueryError(::toml_query::error::Error);
}
errors {
HeaderTypeError(expected: &'static str, got: &'static str) {
description("Header Type Error")
display("Error: Expected {} in header, got {}", expected, got)
}
}
}

View file

@ -33,14 +33,12 @@
while_true, while_true,
)] )]
#[macro_use] extern crate failure;
extern crate error_chain;
extern crate toml; extern crate toml;
extern crate toml_query; extern crate toml_query;
extern crate libimagdiary; extern crate libimagdiary;
extern crate libimagstore; extern crate libimagstore;
pub mod error;
pub mod log; pub mod log;

View file

@ -20,8 +20,8 @@
use libimagdiary::entry::DiaryEntry; use libimagdiary::entry::DiaryEntry;
use libimagstore::store::Entry; use libimagstore::store::Entry;
use error::LogError as LE; use failure::Fallible as Result;
use error::Result; use failure::Error;
use toml::Value; use toml::Value;
use toml_query::read::TomlValueReadTypeExt; use toml_query::read::TomlValueReadTypeExt;
@ -34,13 +34,13 @@ pub trait Log : DiaryEntry {
impl Log for Entry { impl Log for Entry {
fn is_log(&self) -> Result<bool> { fn is_log(&self) -> Result<bool> {
self.get_header().read_bool("log.is_log").map(|v| v.unwrap_or(false)).map_err(From::from) self.get_header().read_bool("log.is_log").map(|v| v.unwrap_or(false)).map_err(Error::from)
} }
fn make_log_entry(&mut self) -> Result<()> { fn make_log_entry(&mut self) -> Result<()> {
self.get_header_mut() self.get_header_mut()
.insert("log.is_log", Value::Boolean(true)) .insert("log.is_log", Value::Boolean(true))
.map_err(LE::from) .map_err(Error::from)
.map(|_| ()) .map(|_| ())
} }