Remove stutter for error variants
Error variants should not end with the same identifier as the enum, i.e., they should not stutter. Found by clippy after setting: avoid-breaking-exported-api = false
This commit is contained in:
parent
08c4a2204a
commit
5cef2f1a8f
|
@ -157,7 +157,7 @@ pub enum Error {
|
||||||
/// Can not find the spent output
|
/// Can not find the spent output
|
||||||
UnknownSpentOutput(OutPoint),
|
UnknownSpentOutput(OutPoint),
|
||||||
/// Can not serialize the spending transaction
|
/// Can not serialize the spending transaction
|
||||||
SerializationError
|
Serialization
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for Error {
|
impl fmt::Display for Error {
|
||||||
|
@ -169,7 +169,7 @@ impl fmt::Display for Error {
|
||||||
#[cfg(feature = "bitcoinconsensus")]
|
#[cfg(feature = "bitcoinconsensus")]
|
||||||
Error::BitcoinConsensus(ref _n) => "bitcoinconsensus verification failed",
|
Error::BitcoinConsensus(ref _n) => "bitcoinconsensus verification failed",
|
||||||
Error::UnknownSpentOutput(ref _point) => "unknown spent output Transaction::verify()",
|
Error::UnknownSpentOutput(ref _point) => "unknown spent output Transaction::verify()",
|
||||||
Error::SerializationError => "can not serialize the spending transaction in Transaction::verify()",
|
Error::Serialization => "can not serialize the spending transaction in Transaction::verify()",
|
||||||
};
|
};
|
||||||
f.write_str(str)
|
f.write_str(str)
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,7 @@ impl std::error::Error for Error {
|
||||||
| EarlyEndOfScript
|
| EarlyEndOfScript
|
||||||
| NumericOverflow
|
| NumericOverflow
|
||||||
| UnknownSpentOutput(_)
|
| UnknownSpentOutput(_)
|
||||||
| SerializationError => None,
|
| Serialization => None,
|
||||||
#[cfg(feature = "bitcoinconsensus")]
|
#[cfg(feature = "bitcoinconsensus")]
|
||||||
BitcoinConsensus(_) => None,
|
BitcoinConsensus(_) => None,
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ pub enum Error {
|
||||||
/// Unable to parse as a standard sighash type.
|
/// Unable to parse as a standard sighash type.
|
||||||
NonStandardSighashType(u32),
|
NonStandardSighashType(u32),
|
||||||
/// Parsing errors from bitcoin_hashes
|
/// Parsing errors from bitcoin_hashes
|
||||||
HashParseError(hashes::Error),
|
HashParse(hashes::Error),
|
||||||
/// The pre-image must hash to the correponding psbt hash
|
/// The pre-image must hash to the correponding psbt hash
|
||||||
InvalidPreimageHashPair {
|
InvalidPreimageHashPair {
|
||||||
/// Hash-type
|
/// Hash-type
|
||||||
|
@ -93,7 +93,7 @@ impl fmt::Display for Error {
|
||||||
Error::NoMorePairs => f.write_str("no more key-value pairs for this psbt map"),
|
Error::NoMorePairs => f.write_str("no more key-value pairs for this psbt map"),
|
||||||
Error::UnexpectedUnsignedTx { expected: ref e, actual: ref a } => write!(f, "different unsigned transaction: expected {}, actual {}", e.txid(), a.txid()),
|
Error::UnexpectedUnsignedTx { expected: ref e, actual: ref a } => write!(f, "different unsigned transaction: expected {}, actual {}", e.txid(), a.txid()),
|
||||||
Error::NonStandardSighashType(ref sht) => write!(f, "non-standard sighash type: {}", sht),
|
Error::NonStandardSighashType(ref sht) => write!(f, "non-standard sighash type: {}", sht),
|
||||||
Error::HashParseError(ref e) => write_err!(f, "hash parse error"; e),
|
Error::HashParse(ref e) => write_err!(f, "hash parse error"; e),
|
||||||
Error::InvalidPreimageHashPair{ref preimage, ref hash, ref hash_type} => {
|
Error::InvalidPreimageHashPair{ref preimage, ref hash, ref hash_type} => {
|
||||||
// directly using debug forms of psbthash enums
|
// directly using debug forms of psbthash enums
|
||||||
write!(f, "Preimage {:?} does not match {:?} hash {:?}", preimage, hash_type, hash )
|
write!(f, "Preimage {:?} does not match {:?} hash {:?}", preimage, hash_type, hash )
|
||||||
|
@ -111,7 +111,7 @@ impl std::error::Error for Error {
|
||||||
use self::Error::*;
|
use self::Error::*;
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
HashParseError(e) => Some(e),
|
HashParse(e) => Some(e),
|
||||||
| InvalidMagic
|
| InvalidMagic
|
||||||
| MissingUtxo
|
| MissingUtxo
|
||||||
| InvalidSeparator
|
| InvalidSeparator
|
||||||
|
@ -135,7 +135,7 @@ impl std::error::Error for Error {
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
impl From<hashes::Error> for Error {
|
impl From<hashes::Error> for Error {
|
||||||
fn from(e: hashes::Error) -> Error {
|
fn from(e: hashes::Error) -> Error {
|
||||||
Error::HashParseError(e)
|
Error::HashParse(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue