diff --git a/src/service.rs b/src/service.rs
index 0cf5ca4d8..18ec9cf02 100644
--- a/src/service.rs
+++ b/src/service.rs
@@ -390,7 +390,8 @@ pub struct AndThen {
impl AndThen
where
A: Service,
- B: Service,
+ A::Error: Into,
+ B: Service,
{
/// Create new `AndThen` combinator
pub fn new(a: A, b: B) -> Self {
@@ -404,7 +405,8 @@ where
impl Service for AndThen
where
A: Service,
- B: Service,
+ A::Error: Into,
+ B: Service,
{
type Request = A::Request;
type Response = B::Response;
@@ -412,11 +414,12 @@ where
type Future = AndThenFuture;
fn poll_ready(&mut self) -> Poll<(), Self::Error> {
- let res = self.a.poll_ready();
- if let Ok(Async::Ready(_)) = res {
- self.b.borrow_mut().poll_ready()
- } else {
- res
+ match self.a.poll_ready() {
+ Ok(Async::Ready(_)) => {
+ self.b.borrow_mut().poll_ready()
+ },
+ Ok(Async::NotReady) => Ok(Async::NotReady),
+ Err(err) => Err(err.into())
}
}
@@ -428,7 +431,8 @@ where
pub struct AndThenFuture
where
A: Service,
- B: Service,
+ A::Error: Into,
+ B: Service,
{
b: Rc>,
fut_b: Option,
@@ -438,7 +442,8 @@ where
impl AndThenFuture
where
A: Service,
- B: Service,
+ A::Error: Into,
+ B: Service,
{
fn new(fut_a: A::Future, b: Rc>) -> Self {
AndThenFuture {
@@ -452,7 +457,8 @@ where
impl Future for AndThenFuture
where
A: Service,
- B: Service,
+ A::Error: Into,
+ B: Service,
{
type Item = B::Response;
type Error = B::Error;
@@ -462,12 +468,13 @@ where
return fut.poll();
}
- match self.fut_a.poll()? {
- Async::Ready(resp) => {
+ match self.fut_a.poll() {
+ Ok(Async::Ready(resp)) => {
self.fut_b = Some(self.b.borrow_mut().call(resp));
self.poll()
}
- Async::NotReady => Ok(Async::NotReady),
+ Ok(Async::NotReady) => Ok(Async::NotReady),
+ Err(err) => Err(err.into())
}
}
}
@@ -496,15 +503,15 @@ impl NewService for AndThenNewService
where
A: NewService<
Response = B::Request,
- Error = B::Error,
Config = B::Config,
InitError = B::InitError,
>,
+ A::Error: Into,
B: NewService,
{
type Request = A::Request;
type Response = B::Response;
- type Error = A::Error;
+ type Error = B::Error;
type Service = AndThen;
type Config = A::Config;
@@ -518,7 +525,8 @@ where
impl Clone for AndThenNewService
where
- A: NewService + Clone,
+ A: NewService + Clone,
+ A::Error: Into,
B: NewService + Clone,
{
fn clone(&self) -> Self {
@@ -557,8 +565,9 @@ where
impl Future for AndThenNewServiceFuture
where
- A: NewService,
- B: NewService,
+ A: NewService,
+ A::Error: Into,
+ B: NewService,
{
type Item = AndThen;
type Error = B::InitError;
@@ -608,7 +617,8 @@ where
impl Service for MapErr
where
A: Service,
- F: Fn(A::Error) -> E + Clone,
+ F: Fn(A::Error) -> E,
+ F: Clone,
{
type Request = A::Request;
type Response = A::Response;
@@ -681,7 +691,7 @@ where
impl Clone for MapErrNewService
where
A: NewService + Clone,
- F: Fn(A::InitError) -> E + Clone,
+ F: Fn(A::Error) -> E + Clone,
{
fn clone(&self) -> Self {
Self {