address: Drop error::Error::description impl

This commit is contained in:
Steven Roose 2019-07-19 11:43:31 +02:00
parent bfdcfee28e
commit e469fec839
No known key found for this signature in database
GPG Key ID: 2F2A88D7F8D68E87
1 changed files with 16 additions and 20 deletions

View File

@ -71,14 +71,21 @@ 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 {
let desc = ::std::error::Error::description(self);
match *self { match *self {
Error::Base58(ref e) => write!(f, "{}: {}", desc, e), Error::Base58(ref e) => write!(f, "base58: {}", e),
Error::Bech32(ref e) => write!(f, "{}: {}", desc, e), Error::Bech32(ref e) => write!(f, "bech32: {}", e),
Error::InvalidWitnessVersion(v) => write!(f, "{}: {}", desc, v), Error::EmptyBech32Payload => write!(f, "the bech32 payload was empty"),
Error::InvalidWitnessProgramLength(l) => write!(f, "{}: {}", desc, l), Error::InvalidWitnessVersion(v) => write!(f, "invalid witness script version: {}", v),
Error::InvalidSegwitV0ProgramLength(l) => write!(f, "{}: {}", desc, l), Error::InvalidWitnessProgramLength(l) => write!(
_ => f.write_str(desc), f,
"the witness program must be between 2 and 40 bytes in length: lengh={}",
l
),
Error::InvalidSegwitV0ProgramLength(l) => write!(
f,
"a v0 witness program must be either of length 20 or 32 bytes: length={}",
l
),
} }
} }
} }
@ -92,19 +99,8 @@ impl ::std::error::Error for Error {
} }
} }
fn description(&self) -> &str { fn description(&self) -> &'static str {
match *self { "std::error::Error::description is deprecated"
Error::Base58(..) => "base58 error",
Error::Bech32(..) => "bech32 error",
Error::EmptyBech32Payload => "the bech32 payload was empty",
Error::InvalidWitnessVersion(..) => "invalid witness script version",
Error::InvalidWitnessProgramLength(..) => {
"the witness program must be between 2 and 40 bytes in length"
},
Error::InvalidSegwitV0ProgramLength(..) => {
"a v0 witness program must be either of length 20 or 32"
},
}
} }
} }