diff options
11 files changed, 42 insertions, 63 deletions
diff --git a/lib/entry/libimagentryfilter/Cargo.toml b/lib/entry/libimagentryfilter/Cargo.toml index 573ea576..cd017512 100644 --- a/lib/entry/libimagentryfilter/Cargo.toml +++ b/lib/entry/libimagentryfilter/Cargo.toml @@ -26,10 +26,12 @@ log = "0.4.0" regex = "1" semver = "0.9" toml = "0.4" -toml-query = "0.7" -error-chain = "0.12" +toml-query = { git = "https://github.com/matthiasbeyer/toml-query", branch = "failure" } +failure = "0.1" +failure_derive = "0.1" libimagstore = { version = "0.9.0", path = "../../../lib/core/libimagstore" } +libimagerror = { version = "0.9.0", path = "../../../lib/core/libimagerror" } libimagentrytag = { version = "0.9.0", path = "../../../lib/entry/libimagentrytag" } [dependencies.clap] diff --git a/lib/entry/libimagentryfilter/src/builtin/header/field_eq.rs b/lib/entry/libimagentryfilter/src/builtin/header/field_eq.rs index 9562dddd..d6d1393c 100644 --- a/lib/entry/libimagentryfilter/src/builtin/header/field_eq.rs +++ b/lib/entry/libimagentryfilter/src/builtin/header/field_eq.rs @@ -23,8 +23,9 @@ use builtin::header::field_path::FieldPath; use builtin::header::field_predicate::FieldPredicate; use builtin::header::field_predicate::Predicate; use filters::failable::filter::FailableFilter; -use error::Result; -use error::FilterError as FE; + +use failure::Fallible as Result; +use failure::Error; use toml::Value; @@ -56,7 +57,7 @@ impl FieldEq { } impl FailableFilter<Entry> for FieldEq { - type Error = FE; + type Error = Error; fn filter(&self, e: &Entry) -> Result<bool> { self.filter.filter(e) diff --git a/lib/entry/libimagentryfilter/src/builtin/header/field_exists.rs b/lib/entry/libimagentryfilter/src/builtin/header/field_exists.rs index 76428874..0032135b 100644 --- a/lib/entry/libimagentryfilter/src/builtin/header/field_exists.rs +++ b/lib/entry/libimagentryfilter/src/builtin/header/field_exists.rs @@ -21,8 +21,9 @@ use libimagstore::store::Entry; use toml_query::read::TomlValueReadExt; use filters::failable::filter::FailableFilter; -use error::Result; -use error::FilterError as FE; + +use failure::Fallible as Result; +use failure::Error; use builtin::header::field_path::FieldPath; @@ -41,10 +42,13 @@ impl FieldExists { } impl FailableFilter<Entry> for FieldExists { - type Error = FE; + type Error = Error; fn filter(&self, e: &Entry) -> Result<bool> { - e.get_header().read(&self.header_field_path[..]).map_err(FE::from).map(|o| o.is_some()) + e.get_header() + .read(&self.header_field_path[..]) + .map_err(Error::from) + .map(|o| o.is_some()) } } diff --git a/lib/entry/libimagentryfilter/src/builtin/header/field_grep.rs b/lib/entry/libimagentryfilter/src/builtin/header/field_grep.rs index 5367eee8..6734bac5 100644 --- a/lib/entry/libimagentryfilter/src/builtin/header/field_grep.rs +++ b/lib/entry/libimagentryfilter/src/builtin/header/field_grep.rs @@ -26,8 +26,9 @@ use builtin::header::field_path::FieldPath; use builtin::header::field_predicate::FieldPredicate; use builtin::header::field_predicate::Predicate; use filters::failable::filter::FailableFilter; -use error::Result; -use error::FilterError as FE; + +use failure::Fallible as Result; +use failure::Error; struct EqGrep{ regex: Regex @@ -60,7 +61,7 @@ impl FieldGrep { } impl FailableFilter<Entry> for FieldGrep { - type Error = FE; + type Error = Error; fn filter(&self, e: &Entry) -> Result<bool> { self.filter.filter(e) diff --git a/lib/entry/libimagentryfilter/src/builtin/header/field_gt.rs b/lib/entry/libimagentryfilter/src/builtin/header/field_gt.rs index b7e629bc..4cbaa74f 100644 --- a/lib/entry/libimagentryfilter/src/builtin/header/field_gt.rs +++ b/lib/entry/libimagentryfilter/src/builtin/header/field_gt.rs @@ -23,8 +23,9 @@ use builtin::header::field_path::FieldPath; use builtin::header::field_predicate::FieldPredicate; use builtin::header::field_predicate::Predicate; use filters::failable::filter::FailableFilter; -use error::Result; -use error::FilterError as FE; + +use failure::Fallible as Result; +use failure::Error; use toml::Value; @@ -72,7 +73,7 @@ impl FieldGt { } impl FailableFilter<Entry> for FieldGt { - type Error = FE; + type Error = Error; fn filter(&self, e: &Entry) -> Result<bool> { self.filter.filter(e) diff --git a/lib/entry/libimagentryfilter/src/builtin/header/field_isempty.rs b/lib/entry/libimagentryfilter/src/builtin/header/field_isempty.rs index d1c4721e..afb4dfe5 100644 --- a/lib/entry/libimagentryfilter/src/builtin/header/field_isempty.rs +++ b/lib/entry/libimagentryfilter/src/builtin/header/field_isempty.rs @@ -22,8 +22,9 @@ use toml_query::read::TomlValueReadExt; use builtin::header::field_path::FieldPath; use filters::failable::filter::FailableFilter; -use error::Result; -use error::FilterError as FE; + +use failure::Fallible as Result; +use failure::Error; use toml::Value; @@ -42,7 +43,7 @@ impl FieldIsEmpty { } impl FailableFilter<Entry> for FieldIsEmpty { - type Error = FE; + type Error = Error; fn filter(&self, e: &Entry) -> Result<bool> { Ok(e diff --git a/lib/entry/libimagentryfilter/src/builtin/header/field_istype.rs b/lib/entry/libimagentryfilter/src/builtin/header/field_istype.rs index a0968d37..2d840517 100644 --- a/lib/entry/libimagentryfilter/src/builtin/header/field_istype.rs +++ b/lib/entry/libimagentryfilter/src/builtin/header/field_istype.rs @@ -23,8 +23,9 @@ use builtin::header::field_path::FieldPath; use builtin::header::field_predicate::FieldPredicate; use builtin::header::field_predicate::Predicate; use filters::failable::filter::FailableFilter; -use error::Result; -use error::FilterError as FE; + +use failure::Fallible as Result; +use failure::Error; use toml::Value; @@ -81,7 +82,7 @@ impl FieldIsType { } impl FailableFilter<Entry> for FieldIsType { - type Error = FE; + type Error = Error; fn filter(&self, e: &Entry) -> Result<bool> { self.filter.filter(e) diff --git a/lib/entry/libimagentryfilter/src/builtin/header/field_lt.rs b/lib/entry/libimagentryfilter/src/builtin/header/field_lt.rs index c9b89fec..0db1aa07 100644 --- a/lib/entry/libimagentryfilter/src/builtin/header/field_lt.rs +++ b/lib/entry/libimagentryfilter/src/builtin/header/field_lt.rs @@ -23,8 +23,9 @@ use builtin::header::field_path::FieldPath; use builtin::header::field_predicate::FieldPredicate; use builtin::header::field_predicate::Predicate; use filters::failable::filter::FailableFilter; -use error::Result; -use error::FilterError as FE; + +use failure::Fallible as Result; +use failure::Error; use toml::Value; @@ -72,7 +73,7 @@ impl FieldLt { } impl FailableFilter<Entry> for FieldLt { - type Error = FE; + type Error = Error; fn filter(&self, e: &Entry) -> Result<bool> { self.filter.filter(e) diff --git a/lib/entry/libimagentryfilter/src/builtin/header/field_predicate.rs b/lib/entry/libimagentryfilter/src/builtin/header/field_predicate.rs index 5a7dbb9b..520ec5c1 100644 --- a/lib/entry/libimagentryfilter/src/builtin/header/field_predicate.rs +++ b/lib/entry/libimagentryfilter/src/builtin/header/field_predicate.rs @@ -24,8 +24,9 @@ use toml::Value; use builtin::header::field_path::FieldPath; use filters::failable::filter::FailableFilter; -use error::Result; -use error::FilterError as FE; + +use failure::Fallible as Result; +use failure::Error; pub trait Predicate { fn evaluate(&self, &Value) -> bool; @@ -53,7 +54,7 @@ impl<P: Predicate> FieldPredicate<P> { } impl<P: Predicate> FailableFilter<Entry> for FieldPredicate<P> { - type Error = FE; + type Error = Error; fn filter(&self, e: &Entry) -> Result<bool> { Ok(e.get_header() diff --git a/lib/entry/libimagentryfilter/src/error.rs b/lib/entry/libimagentryfilter/src/error.rs deleted file mode 100644 index 370b3fb9..00000000 --- a/lib/entry/libimagentryfilter/src/error.rs +++ /dev/null @@ -1,34 +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 { - FilterError, FilterErrorKind, ResultExt, Result; - } - - foreign_links { - TomlQueryError(::toml_query::error::Error); - } - - errors { - } - -} - diff --git a/lib/entry/libimagentryfilter/src/lib.rs b/lib/entry/libimagentryfilter/src/lib.rs index b7870fe1..2a58f2af 100644 --- a/lib/entry/libimagentryfilter/src/lib.rs +++ b/lib/entry/libimagentryfilter/src/lib.rs @@ -38,16 +38,16 @@ extern crate regex; extern crate semver; extern crate toml; extern crate toml_query; -#[macro_use] extern crate error_chain; +extern crate failure; extern crate libimagstore; extern crate libimagentrytag; +extern crate libimagerror; // core functionality modules of the crate, // these depend only on libimagstore pub mod builtin; -pub mod error; // extended functionality of the crate // these depend on other internal libraries than libimagstore and use the upper core modules for |