Remove unnecessary network::Error::Detail variant

This commit is contained in:
Carl Dong 2018-08-21 01:07:27 -07:00
parent 95303a1d28
commit d12a861f85
2 changed files with 2 additions and 9 deletions

View File

@ -22,7 +22,7 @@ use std::thread;
use std::sync::mpsc::{channel, Receiver};
use network::constants::Network;
use network::{self, message};
use network::message;
use network::message::NetworkMessage::Verack;
use network::socket::Socket;
use util;
@ -39,9 +39,7 @@ pub trait Listener {
fn start(&self) -> Result<(Receiver<message::SocketResponse>, Socket), util::Error> {
// Open socket
let mut ret_sock = Socket::new(self.network());
if let Err(e) = ret_sock.connect(self.peer(), self.port()) {
return Err(util::Error::Network(network::Error::Detail("listener".to_owned(), Box::new(e))));
}
ret_sock.connect(self.peer(), self.port())?;
let mut sock = ret_sock.clone();
let (recv_tx, recv_rx) = channel();

View File

@ -43,15 +43,12 @@ pub enum Error {
SocketMutexPoisoned,
/// Not connected to peer
SocketNotConnectedToPeer,
/// Error propagated from subsystem
Detail(String, Box<Error>),
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Error::Io(ref e) => fmt::Display::fmt(e, f),
Error::Detail(ref s, ref e) => write!(f, "{}: {}", s, e),
ref x => f.write_str(error::Error::description(x)),
}
}
@ -61,7 +58,6 @@ impl error::Error for Error {
fn cause(&self) -> Option<&error::Error> {
match *self {
Error::Io(ref e) => Some(e),
Error::Detail(_, ref e) => Some(e),
_ => None
}
}
@ -71,7 +67,6 @@ impl error::Error for Error {
Error::Io(ref e) => e.description(),
Error::SocketMutexPoisoned => "socket mutex was poisoned",
Error::SocketNotConnectedToPeer => "not connected to peer",
Error::Detail(_, ref e) => e.description(),
}
}
}