Import error variants within dislay impl
In an effort to reduce the number of lines of code import the error variants locally within the `Display` impl on `Error`. Refactor only, no logic changes.
This commit is contained in:
parent
9d7791fcd6
commit
e2014cba1b
|
@ -49,28 +49,29 @@ 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 {
|
||||||
|
use Error::*;
|
||||||
|
|
||||||
match *self {
|
match *self {
|
||||||
Error::Base58(ref e) => write_err!(f, "base58 address encoding error"; e),
|
Base58(ref e) => write_err!(f, "base58 address encoding error"; e),
|
||||||
Error::Bech32(ref e) => write_err!(f, "bech32 address encoding error"; e),
|
Bech32(ref e) => write_err!(f, "bech32 address encoding error"; e),
|
||||||
Error::EmptyBech32Payload => write!(f, "the bech32 payload was empty"),
|
EmptyBech32Payload => write!(f, "the bech32 payload was empty"),
|
||||||
Error::InvalidBech32Variant { expected, found } => write!(
|
InvalidBech32Variant { expected, found } => write!(
|
||||||
f,
|
f,
|
||||||
"invalid bech32 checksum variant found {:?} when {:?} was expected",
|
"invalid bech32 checksum variant found {:?} when {:?} was expected",
|
||||||
found, expected
|
found, expected
|
||||||
),
|
),
|
||||||
Error::WitnessVersion(ref e) => write_err!(f, "witness version construction error"; e),
|
WitnessVersion(ref e) => write_err!(f, "witness version construction error"; e),
|
||||||
Error::WitnessProgram(ref e) => write_err!(f, "witness program error"; e),
|
WitnessProgram(ref e) => write_err!(f, "witness program error"; e),
|
||||||
Error::UncompressedPubkey =>
|
UncompressedPubkey =>
|
||||||
write!(f, "an uncompressed pubkey was used where it is not allowed"),
|
write!(f, "an uncompressed pubkey was used where it is not allowed"),
|
||||||
Error::ExcessiveScriptSize => write!(f, "script size exceed 520 bytes"),
|
ExcessiveScriptSize => write!(f, "script size exceed 520 bytes"),
|
||||||
Error::UnrecognizedScript =>
|
UnrecognizedScript => write!(f, "script is not a p2pkh, p2sh or witness program"),
|
||||||
write!(f, "script is not a p2pkh, p2sh or witness program"),
|
UnknownAddressType(ref s) => write!(
|
||||||
Error::UnknownAddressType(ref s) => write!(
|
|
||||||
f,
|
f,
|
||||||
"unknown address type: '{}' is either invalid or not supported in rust-bitcoin",
|
"unknown address type: '{}' is either invalid or not supported in rust-bitcoin",
|
||||||
s
|
s
|
||||||
),
|
),
|
||||||
Error::NetworkValidation { required, found, ref address } => {
|
NetworkValidation { required, found, ref address } => {
|
||||||
write!(f, "address ")?;
|
write!(f, "address ")?;
|
||||||
address.fmt_internal(f)?; // Using fmt_internal in order to remove the "Address<NetworkUnchecked>(..)" wrapper
|
address.fmt_internal(f)?; // Using fmt_internal in order to remove the "Address<NetworkUnchecked>(..)" wrapper
|
||||||
write!(
|
write!(
|
||||||
|
|
Loading…
Reference in New Issue