diff --git a/lib/domain/libimagbookmark/src/collection.rs b/lib/domain/libimagbookmark/src/collection.rs index 206e31cd..6a8e9367 100644 --- a/lib/domain/libimagbookmark/src/collection.rs +++ b/lib/domain/libimagbookmark/src/collection.rs @@ -29,7 +29,7 @@ use std::ops::DerefMut; use regex::Regex; use error::BookmarkErrorKind as BEK; -use error::MapErrInto; +use error::ResultExt; use result::Result; use module_path::ModuleEntryPath; @@ -81,14 +81,14 @@ impl<'a> BookmarkCollection<'a> { store: store, } }) - .map_err_into(BEK::StoreReadError) + .chain_err(|| BEK::StoreReadError) } pub fn get(store: &'a Store, name: &str) -> Result> { ModuleEntryPath::new(name) .into_storeid() .and_then(|id| store.get(id)) - .map_err_into(BEK::StoreReadError) + .chain_err(|| BEK::StoreReadError) .and_then(|fle| { match fle { None => Err(BEK::CollectionNotFound.into_error()), @@ -104,11 +104,11 @@ impl<'a> BookmarkCollection<'a> { ModuleEntryPath::new(name) .into_storeid() .and_then(|id| store.delete(id)) - .map_err_into(BEK::StoreReadError) + .chain_err(|| BEK::StoreReadError) } pub fn links(&self) -> Result { - self.fle.get_external_links(&self.store).map_err_into(BEK::LinkError) + self.fle.get_external_links(&self.store).chain_err(|| BEK::LinkError) } pub fn link_entries(&self) -> Result> { @@ -117,22 +117,22 @@ impl<'a> BookmarkCollection<'a> { self.fle .get_internal_links() .map(|v| v.filter(|id| is_external_link_storeid(id)).collect()) - .map_err_into(BEK::StoreReadError) + .chain_err(|| BEK::StoreReadError) } pub fn add_link(&mut self, l: Link) -> Result<()> { use link::IntoUrl; l.into_url() - .and_then(|url| self.add_external_link(self.store, url).map_err_into(BEK::LinkingError)) - .map_err_into(BEK::LinkError) + .and_then(|url| self.add_external_link(self.store, url).chain_err(|| BEK::LinkingError)) + .chain_err(|| BEK::LinkError) } pub fn get_links_matching(&self, r: Regex) -> Result> { use self::iter::IntoLinksMatchingRegexIter; self.get_external_links(self.store) - .map_err_into(BEK::LinkError) + .chain_err(|| BEK::LinkError) .map(|iter| iter.matching_regex(r)) } @@ -141,9 +141,9 @@ impl<'a> BookmarkCollection<'a> { l.into_url() .and_then(|url| { - self.remove_external_link(self.store, url).map_err_into(BEK::LinkingError) + self.remove_external_link(self.store, url).chain_err(|| BEK::LinkingError) }) - .map_err_into(BEK::LinkError) + .chain_err(|| BEK::LinkError) } } @@ -151,7 +151,7 @@ impl<'a> BookmarkCollection<'a> { pub mod iter { use link::Link; use result::Result; - use error::{MapErrInto, BookmarkErrorKind as BEK}; + use error::{ResultExt, BookmarkErrorKind as BEK}; pub struct LinkIter(I) where I: Iterator; @@ -194,7 +194,7 @@ pub mod iter { loop { let n = match self.0.next() { Some(Ok(n)) => n, - Some(Err(e)) => return Some(Err(e).map_err_into(BEK::LinkError)), + Some(Err(e)) => return Some(Err(e).chain_err(|| BEK::LinkError)), None => return None, }; diff --git a/lib/domain/libimagbookmark/src/error.rs b/lib/domain/libimagbookmark/src/error.rs index 671c0ead..34b5735d 100644 --- a/lib/domain/libimagbookmark/src/error.rs +++ b/lib/domain/libimagbookmark/src/error.rs @@ -17,6 +17,10 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // +use std::error::Error; + +use libimagerror::into::IntoError; + error_chain! { types { BookmarkError, BookmarkErrorKind, ResultExt, Result; @@ -51,10 +55,6 @@ error_chain! { } } -pub use self::error::BookmarkError; -pub use self::error::BookmarkErrorKind; -pub use self::error::MapErrInto; - impl IntoError for BookmarkErrorKind { type Target = BookmarkError; @@ -62,7 +62,7 @@ impl IntoError for BookmarkErrorKind { BookmarkError::from_kind(self) } - fn into_error_with_cause(self, cause: Box) -> Self::Target { + fn into_error_with_cause(self, _: Box) -> Self::Target { BookmarkError::from_kind(self) } } diff --git a/lib/domain/libimagbookmark/src/lib.rs b/lib/domain/libimagbookmark/src/lib.rs index 7176bfcf..00d94f61 100644 --- a/lib/domain/libimagbookmark/src/lib.rs +++ b/lib/domain/libimagbookmark/src/lib.rs @@ -40,7 +40,7 @@ extern crate regex; #[macro_use] extern crate error_chain; #[macro_use] extern crate libimagstore; -#[macro_use] extern crate libimagerror; +extern crate libimagerror; extern crate libimagentrylink; module_entry_path_mod!("bookmark"); diff --git a/lib/domain/libimagbookmark/src/link.rs b/lib/domain/libimagbookmark/src/link.rs index 1da91c8a..acc68e60 100644 --- a/lib/domain/libimagbookmark/src/link.rs +++ b/lib/domain/libimagbookmark/src/link.rs @@ -67,9 +67,9 @@ impl IntoUrl for Link { fn into_url(self) -> Result { use error::BookmarkErrorKind as BEK; - use error::MapErrInto; + use error::ResultExt; - Url::parse(&self[..]).map_err_into(BEK::LinkParsingError) + Url::parse(&self[..]).chain_err(|| BEK::LinkParsingError) } }