diff --git a/lib/etc/libimagnotification/Cargo.toml b/lib/etc/libimagnotification/Cargo.toml index 2cfc5216..6f24b8d3 100644 --- a/lib/etc/libimagnotification/Cargo.toml +++ b/lib/etc/libimagnotification/Cargo.toml @@ -20,8 +20,9 @@ is-it-maintained-open-issues = { repository = "matthiasbeyer/imag" } maintenance = { status = "actively-developed" } [dependencies] -notify-rust = "3.4.2" -error-chain = "0.12" +notify-rust = "3.4.2" +failure = "0.1" +failure_derive = "0.1" libimagerror = { version = "0.9.0", path = "../../../lib/core/libimagerror" } diff --git a/lib/etc/libimagnotification/src/error.rs b/lib/etc/libimagnotification/src/error.rs deleted file mode 100644 index 27ea3694..00000000 --- a/lib/etc/libimagnotification/src/error.rs +++ /dev/null @@ -1,36 +0,0 @@ -// -// imag - the personal information management suite for the commandline -// Copyright (C) 2015-2018 Matthias Beyer 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 { - NotificationError, NotificationErrorKind, ResultExt, Result; - } - - foreign_links { - NotifyError(::notify_rust::error::Error); - } - - errors { - Unknown { - description("Unknown Error") - display("Unknown Error") - } - } -} - diff --git a/lib/etc/libimagnotification/src/lib.rs b/lib/etc/libimagnotification/src/lib.rs index 6bf0f0e1..a64b3f43 100644 --- a/lib/etc/libimagnotification/src/lib.rs +++ b/lib/etc/libimagnotification/src/lib.rs @@ -34,11 +34,10 @@ )] extern crate notify_rust; -#[macro_use] extern crate error_chain; +extern crate failure; extern crate libimagerror; -pub mod error; pub mod notificator; pub mod result_notification; diff --git a/lib/etc/libimagnotification/src/notificator.rs b/lib/etc/libimagnotification/src/notificator.rs index 822dc92b..5ef97395 100644 --- a/lib/etc/libimagnotification/src/notificator.rs +++ b/lib/etc/libimagnotification/src/notificator.rs @@ -17,7 +17,7 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // -use error::Result; +use failure::Fallible as Result; /// A Notificator provides a function that can be called to notify about a certain object. /// @@ -34,7 +34,7 @@ pub mod default { use std::fmt::Debug; use std::fmt::Display; - use error::Result; + use failure::Fallible as Result; use notify_rust::Notification as RustNotification; use notify_rust::NotificationUrgency; diff --git a/lib/etc/libimagnotification/src/result_notification.rs b/lib/etc/libimagnotification/src/result_notification.rs index 8f700caa..5d33825f 100644 --- a/lib/etc/libimagnotification/src/result_notification.rs +++ b/lib/etc/libimagnotification/src/result_notification.rs @@ -31,12 +31,11 @@ pub mod err { use notify_rust::Notification as RustNotification; use notify_rust::NotificationUrgency; - use error::ResultExt; - use error::NotificationErrorKind as NEK; use notificator::default::Urgency; use notificator::default::Notification; use notificator::Notificator; - use error::Result; + use failure::Fallible as Result; + use failure::err_msg; #[derive(Debug, Default, Clone)] pub struct ErrorNotification(Notification, usize); @@ -64,7 +63,9 @@ pub mod err { n.summary("[Error]"); n.urgency(urgency); n.body(e.description()); - try!(n.finalize().show().map(|_| ()).chain_err(|| NEK::Unknown)); + let _ = n.finalize() + .show() + .map_err(|_| err_msg("Notification error"))?; if u > 0 { e.cause().map(|cause| trace_notify(urgency, cause, u - 1)); @@ -105,7 +106,8 @@ pub mod ok { use notificator::default::Notification; use notificator::Notificator; - use error::Result; + use failure::Fallible as Result; + use failure::err_msg; #[derive(Debug, Default, Clone)] pub struct OkNotification(Notification); @@ -127,8 +129,10 @@ pub mod ok { n.summary("[Ok]"); n.urgency(self.0.urgency.clone().into()); n.body(&"< >".to_owned()); - n.finalize().show().map(|_| ())?; - Ok(()) + n.finalize() + .show() + .map(|_| ()) + .map_err(|_| err_msg("Notification error")) } }