Improve error display imlps
Improve the `Error` `Display` impls by doing: - Be more terse by importing the error enum's variants. - Do not use capital letters for error messages.
This commit is contained in:
parent
22c7aa8808
commit
6c9d9d9c36
|
@ -199,12 +199,14 @@ 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::Hex(ref e) => write_err!(f, "Signature hex decoding error"; e),
|
Hex(ref e) => write_err!(f, "signature hex decoding error"; e),
|
||||||
Error::NonStandardSighashType(hash_ty) =>
|
NonStandardSighashType(hash_ty) =>
|
||||||
write!(f, "Non standard signature hash type {}", hash_ty),
|
write!(f, "non-standard signature hash type {}", hash_ty),
|
||||||
Error::EmptySignature => write!(f, "Empty ECDSA signature"),
|
EmptySignature => write!(f, "empty ECDSA signature"),
|
||||||
Error::Secp256k1(ref e) => write_err!(f, "invalid ECDSA signature"; e),
|
Secp256k1(ref e) => write_err!(f, "invalid ECDSA signature"; e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,12 +41,14 @@ 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, "key base58 error"; e),
|
Base58(ref e) => write_err!(f, "key base58 error"; e),
|
||||||
Error::Secp256k1(ref e) => write_err!(f, "key secp256k1 error"; e),
|
Secp256k1(ref e) => write_err!(f, "key secp256k1 error"; e),
|
||||||
Error::InvalidKeyPrefix(ref b) => write!(f, "key prefix invalid: {}", b),
|
InvalidKeyPrefix(ref b) => write!(f, "key prefix invalid: {}", b),
|
||||||
Error::Hex(ref e) => write_err!(f, "key hex decoding error"; e),
|
Hex(ref e) => write_err!(f, "key hex decoding error"; e),
|
||||||
Error::InvalidHexLength(got) =>
|
InvalidHexLength(got) =>
|
||||||
write!(f, "PublicKey hex should be 66 or 130 digits long, got: {}", got),
|
write!(f, "PublicKey hex should be 66 or 130 digits long, got: {}", got),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue