diff --git a/bitcoin/src/crypto/ecdsa.rs b/bitcoin/src/crypto/ecdsa.rs index 1bdb347d..1b0c3c69 100644 --- a/bitcoin/src/crypto/ecdsa.rs +++ b/bitcoin/src/crypto/ecdsa.rs @@ -199,12 +199,14 @@ pub enum Error { impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + use Error::*; + match *self { - Error::Hex(ref e) => write_err!(f, "Signature hex decoding error"; e), - Error::NonStandardSighashType(hash_ty) => - write!(f, "Non standard signature hash type {}", hash_ty), - Error::EmptySignature => write!(f, "Empty ECDSA signature"), - Error::Secp256k1(ref e) => write_err!(f, "invalid ECDSA signature"; e), + Hex(ref e) => write_err!(f, "signature hex decoding error"; e), + NonStandardSighashType(hash_ty) => + write!(f, "non-standard signature hash type {}", hash_ty), + EmptySignature => write!(f, "empty ECDSA signature"), + Secp256k1(ref e) => write_err!(f, "invalid ECDSA signature"; e), } } } diff --git a/bitcoin/src/crypto/key.rs b/bitcoin/src/crypto/key.rs index e870592c..dbe6e97d 100644 --- a/bitcoin/src/crypto/key.rs +++ b/bitcoin/src/crypto/key.rs @@ -41,12 +41,14 @@ pub enum Error { impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + use Error::*; + match *self { - Error::Base58(ref e) => write_err!(f, "key base58 error"; e), - Error::Secp256k1(ref e) => write_err!(f, "key secp256k1 error"; e), - Error::InvalidKeyPrefix(ref b) => write!(f, "key prefix invalid: {}", b), - Error::Hex(ref e) => write_err!(f, "key hex decoding error"; e), - Error::InvalidHexLength(got) => + Base58(ref e) => write_err!(f, "key base58 error"; e), + Secp256k1(ref e) => write_err!(f, "key secp256k1 error"; e), + InvalidKeyPrefix(ref b) => write!(f, "key prefix invalid: {}", b), + Hex(ref e) => write_err!(f, "key hex decoding error"; e), + InvalidHexLength(got) => write!(f, "PublicKey hex should be 66 or 130 digits long, got: {}", got), } }