Remove deprecated std::error::Error::description

This commit is contained in:
Steven Roose 2019-09-09 11:06:38 +01:00
parent 5373428510
commit d02318f423
No known key found for this signature in database
GPG Key ID: 2F2A88D7F8D68E87
1 changed files with 17 additions and 24 deletions

View File

@ -91,17 +91,22 @@ pub enum Error {
impl fmt::Display for Error { impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self { match *self {
Error::Io(ref e) => fmt::Display::fmt(e, f), Error::Io(ref e) => write!(f, "I/O error: {}", e),
Error::ByteOrder(ref e) => fmt::Display::fmt(e, f), Error::ByteOrder(ref e) => write!(f, "byteorder error: {}", e),
Error::Psbt(ref e) => fmt::Display::fmt(e, f), Error::Psbt(ref e) => write!(f, "PSBT error: {}", e),
Error::UnexpectedNetworkMagic { expected: ref e, actual: ref a } => write!(f, "{}: expected {}, actual {}", error::Error::description(self), e, a), Error::UnexpectedNetworkMagic { expected: ref e, actual: ref a } => write!(f,
Error::OversizedVectorAllocation { requested: ref r, max: ref m } => write!(f, "{}: requested {}, maximum {}", error::Error::description(self), r, m), "unexpected network magic: expected {}, actual {}", e, a),
Error::InvalidChecksum { expected: ref e, actual: ref a } => write!(f, "{}: expected {}, actual {}", error::Error::description(self), e[..].to_hex(), a[..].to_hex()), Error::OversizedVectorAllocation { requested: ref r, max: ref m } => write!(f,
Error::UnknownNetworkMagic(ref m) => write!(f, "{}: {}", error::Error::description(self), m), "allocation of oversized vector: requested {}, maximum {}", r, m),
Error::ParseFailed(ref e) => write!(f, "{}: {}", error::Error::description(self), e), Error::InvalidChecksum { expected: ref e, actual: ref a } => write!(f,
Error::UnsupportedSegwitFlag(ref swflag) => write!(f, "{}: {}", error::Error::description(self), swflag), "invalid checksum: expected {}, actual {}", e.to_hex(), a.to_hex()),
Error::UnrecognizedNetworkCommand(ref nwcmd) => write!(f, "{}: {}", error::Error::description(self), nwcmd), Error::UnknownNetworkMagic(ref m) => write!(f, "unknown network magic: {}", m),
Error::UnexpectedHexDigit(ref d) => write!(f, "{}: {}", error::Error::description(self), d), 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 { fn description(&self) -> &str {
match *self { "Bitcoin encoding error"
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",
}
} }
} }