From bccdd06794d4b7f167ad881b919dfbeda2edb1b2 Mon Sep 17 00:00:00 2001 From: Carl Dong Date: Tue, 21 Aug 2018 01:42:12 -0700 Subject: [PATCH] Replace catch-all match arms with specific ones --- src/network/mod.rs | 4 ++-- src/network/serialize.rs | 10 +++++++++- src/util/mod.rs | 6 ++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/network/mod.rs b/src/network/mod.rs index a7e6f7ea..e93876a4 100644 --- a/src/network/mod.rs +++ b/src/network/mod.rs @@ -49,7 +49,7 @@ 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), - ref x => f.write_str(error::Error::description(x)), + Error::SocketMutexPoisoned | Error::SocketNotConnectedToPeer => f.write_str(error::Error::description(self)), } } } @@ -58,7 +58,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::Io(ref e) => Some(e), - _ => None + Error::SocketMutexPoisoned | Error::SocketNotConnectedToPeer => None, } } diff --git a/src/network/serialize.rs b/src/network/serialize.rs index ce5e3443..81df314d 100644 --- a/src/network/serialize.rs +++ b/src/network/serialize.rs @@ -105,7 +105,15 @@ impl error::Error for Error { Error::Base58(ref e) => Some(e), Error::Bech32(ref e) => Some(e), Error::ByteOrder(ref e) => Some(e), - _ => None + Error::UnexpectedNetworkMagic { .. } + | Error::OversizedVectorAllocation { .. } + | Error::InvalidChecksum { .. } + | Error::UnknownNetworkMagic(..) + | Error::ParseFailed(..) + | Error::UnsupportedWitnessVersion(..) + | Error::UnsupportedSegwitFlag(..) + | Error::UnrecognizedNetworkCommand(..) + | Error::UnexpectedHexDigit(..) => None, } } diff --git a/src/util/mod.rs b/src/util/mod.rs index 08d01ae3..0188c26b 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -80,7 +80,8 @@ impl fmt::Display for Error { match *self { Error::Secp256k1(ref e) => fmt::Display::fmt(e, f), Error::Serialize(ref e) => fmt::Display::fmt(e, f), - ref x => f.write_str(error::Error::description(x)) + Error::Network(ref e) => fmt::Display::fmt(e, f), + Error::SpvBadProofOfWork | Error::SpvBadTarget => f.write_str(error::Error::description(self)), } } } @@ -90,7 +91,8 @@ impl error::Error for Error { match *self { Error::Secp256k1(ref e) => Some(e), Error::Serialize(ref e) => Some(e), - _ => None + Error::Network(ref e) => Some(e), + Error::SpvBadProofOfWork | Error::SpvBadTarget => None } }