From d02318f423e47a3966422f2dfe4530db22fe38f0 Mon Sep 17 00:00:00 2001 From: Steven Roose Date: Mon, 9 Sep 2019 11:06:38 +0100 Subject: [PATCH] Remove deprecated std::error::Error::description --- src/consensus/encode.rs | 41 +++++++++++++++++------------------------ 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/src/consensus/encode.rs b/src/consensus/encode.rs index bdb26c9e..07a47b97 100644 --- a/src/consensus/encode.rs +++ b/src/consensus/encode.rs @@ -91,17 +91,22 @@ pub enum 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::ByteOrder(ref e) => fmt::Display::fmt(e, f), - Error::Psbt(ref e) => fmt::Display::fmt(e, f), - Error::UnexpectedNetworkMagic { expected: ref e, actual: ref a } => write!(f, "{}: expected {}, actual {}", error::Error::description(self), e, a), - Error::OversizedVectorAllocation { requested: ref r, max: ref m } => write!(f, "{}: requested {}, maximum {}", error::Error::description(self), r, m), - Error::InvalidChecksum { expected: ref e, actual: ref a } => write!(f, "{}: expected {}, actual {}", error::Error::description(self), e[..].to_hex(), a[..].to_hex()), - Error::UnknownNetworkMagic(ref m) => write!(f, "{}: {}", error::Error::description(self), m), - Error::ParseFailed(ref e) => write!(f, "{}: {}", error::Error::description(self), e), - Error::UnsupportedSegwitFlag(ref swflag) => write!(f, "{}: {}", error::Error::description(self), swflag), - Error::UnrecognizedNetworkCommand(ref nwcmd) => write!(f, "{}: {}", error::Error::description(self), nwcmd), - Error::UnexpectedHexDigit(ref d) => write!(f, "{}: {}", error::Error::description(self), d), + Error::Io(ref e) => write!(f, "I/O error: {}", e), + Error::ByteOrder(ref e) => write!(f, "byteorder error: {}", e), + Error::Psbt(ref e) => write!(f, "PSBT error: {}", e), + Error::UnexpectedNetworkMagic { expected: ref e, actual: ref a } => write!(f, + "unexpected network magic: expected {}, actual {}", e, a), + Error::OversizedVectorAllocation { requested: ref r, max: ref m } => write!(f, + "allocation of oversized vector: requested {}, maximum {}", r, m), + Error::InvalidChecksum { expected: ref e, actual: ref a } => write!(f, + "invalid checksum: expected {}, actual {}", e.to_hex(), a.to_hex()), + Error::UnknownNetworkMagic(ref m) => write!(f, "unknown network magic: {}", m), + Error::ParseFailed(ref e) => write!(f, "parse failed: {}", e), + Error::UnsupportedSegwitFlag(ref swflag) => write!(f, + "unsupported segwit version: {}", swflag), + Error::UnrecognizedNetworkCommand(ref nwcmd) => write!(f, + "unrecognized network command: {}", nwcmd), + Error::UnexpectedHexDigit(ref d) => write!(f, "unexpected hex digit: {}", d), } } } @@ -124,19 +129,7 @@ impl error::Error for Error { } fn description(&self) -> &str { - match *self { - Error::Io(ref e) => e.description(), - Error::ByteOrder(ref e) => e.description(), - Error::Psbt(ref e) => e.description(), - Error::UnexpectedNetworkMagic { .. } => "unexpected network magic", - Error::OversizedVectorAllocation { .. } => "allocation of oversized vector requested", - Error::InvalidChecksum { .. } => "invalid checksum", - Error::UnknownNetworkMagic(..) => "unknown network magic", - Error::ParseFailed(..) => "parse failed", - Error::UnsupportedSegwitFlag(..) => "unsupported segwit version", - Error::UnrecognizedNetworkCommand(..) => "unrecognized network command", - Error::UnexpectedHexDigit(..) => "unexpected hex digit", - } + "Bitcoin encoding error" } }