title: How to return an error to caller from an actix-web handler with client?
body: <p>I created a server with actix_web that will connect through GET to another service using actix client and return body on success or error on error. I have been able to return the body but have no clue about how to return the error.</p>
  
  <p>This is my handler:</p>
  
  <pre><code>fn echo_client(client: web::Data&lt;Client&gt;) -&gt; impl Future&lt;Item = HttpResponse, Error = Error&gt; {
      client
          .get("127.0.0.1:9596/echo/javier") // &lt;- Create request builder
          .header("User-Agent", "Actix-web")
          //.finish().unwrap()
          .send() // &lt;- Send http request
          .map_err(|_| ())
          //.map_err(Error::from)
          .and_then(|response| {
              response
                  .body()
                  .and_then(|body| {
                      println!("{:?}", body);
                      Ok(HttpResponse::Ok().body(body))
                  })
                  .map_err(|error| Err(error.error_response()))
          })
  }
  </code></pre>