From b269d6184edd742c3f75fe497481c8c12653b84b Mon Sep 17 00:00:00 2001 From: David Date: Fri, 30 Nov 2018 08:34:04 +0100 Subject: [PATCH] Use UpgradeError::into_io_error (#709) * Use UpgradeError::into_io_error * Update core/src/transport/upgrade.rs Co-Authored-By: dvdplm * Update core/src/transport/upgrade.rs Co-Authored-By: dvdplm --- core/src/transport/upgrade.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/core/src/transport/upgrade.rs b/core/src/transport/upgrade.rs index 79927036..2193c0ec 100644 --- a/core/src/transport/upgrade.rs +++ b/core/src/transport/upgrade.rs @@ -22,7 +22,7 @@ use futures::prelude::*; use multiaddr::Multiaddr; use crate::{ transport::Transport, - upgrade::{OutboundUpgrade, InboundUpgrade, UpgradeInfo, apply_inbound, apply_outbound} + upgrade::{OutboundUpgrade, InboundUpgrade, UpgradeInfo, apply_inbound, apply_outbound, UpgradeError} }; use tokio_io::{AsyncRead, AsyncWrite}; @@ -60,9 +60,9 @@ where match self.inner.dial(addr.clone()) { Ok(outbound) => { let future = outbound - .and_then(move |x| apply_outbound(x, upgrade).map_err(|e| { - std::io::Error::new(std::io::ErrorKind::Other, e) - })); + .and_then(move |x| { + apply_outbound(x, upgrade).map_err(UpgradeError::into_io_error) + }); Ok(Box::new(future)) } Err((dialer, addr)) => Err((Upgrade::new(dialer, upgrade), addr)) @@ -77,9 +77,9 @@ where .map(move |(future, addr)| { let upgrade = upgrade.clone(); let future = future - .and_then(move |x| apply_inbound(x, upgrade).map_err(|e| { - std::io::Error::new(std::io::ErrorKind::Other, e) - })); + .and_then(move |x| { + apply_inbound(x, upgrade).map_err(UpgradeError::into_io_error) + }); (Box::new(future) as Box<_>, addr) }); Ok((Box::new(stream), addr))