diff --git a/tower-watch/src/lib.rs b/tower-watch/src/lib.rs index e740892..ac61fd8 100644 --- a/tower-watch/src/lib.rs +++ b/tower-watch/src/lib.rs @@ -3,6 +3,7 @@ extern crate futures; extern crate futures_watch; extern crate tower_service; +use std::{fmt, error}; use futures::{Async, Future, Poll, Stream}; use futures_watch::{Watch, WatchError}; use tower_service::Service; @@ -75,6 +76,32 @@ where } } +// ==== impl Error ==== + +impl fmt::Display for Error +where + E: fmt::Display +{ + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + Error::WatchError(_) => f.pad("watch error"), + Error::Inner(e) => fmt::Display::fmt(e, f), + } + } +} + +impl error::Error for Error +where + E: error::Error, +{ + fn cause(&self) -> Option<&error::Error> { + match self { + Error::WatchError(_) => None, + Error::Inner(e) => e.cause(), + } + } +} + // ==== impl Bind ==== impl Bind for F