Deprecate Error::description
This commit is contained in:
parent
a148e06736
commit
654232a3dc
|
@ -105,15 +105,7 @@ 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 {
|
||||||
f.write_str(error::Error::description(self))
|
let str = match *self {
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl error::Error for Error {
|
|
||||||
fn cause(&self) -> Option<&error::Error> { None }
|
|
||||||
|
|
||||||
fn description(&self) -> &'static str {
|
|
||||||
match *self {
|
|
||||||
Error::NonMinimalPush => "non-minimal datapush",
|
Error::NonMinimalPush => "non-minimal datapush",
|
||||||
Error::EarlyEndOfScript => "unexpected end of script",
|
Error::EarlyEndOfScript => "unexpected end of script",
|
||||||
Error::NumericOverflow => "numeric overflow (number on stack larger than 4 bytes)",
|
Error::NumericOverflow => "numeric overflow (number on stack larger than 4 bytes)",
|
||||||
|
@ -123,7 +115,15 @@ impl error::Error for Error {
|
||||||
Error::UnknownSpentOutput(ref _point) => "unknown spent output Transaction::verify()",
|
Error::UnknownSpentOutput(ref _point) => "unknown spent output Transaction::verify()",
|
||||||
#[cfg(feature="bitcoinconsensus")]
|
#[cfg(feature="bitcoinconsensus")]
|
||||||
Error::SerializationError => "can not serialize the spending transaction in Transaction::verify()",
|
Error::SerializationError => "can not serialize the spending transaction in Transaction::verify()",
|
||||||
}
|
};
|
||||||
|
f.write_str(str)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
|
impl error::Error for Error {
|
||||||
|
fn description(&self) -> &str {
|
||||||
|
"description() is deprecated; use Display"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,15 +128,10 @@ impl fmt::Display for ParseOutPointError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
impl ::std::error::Error for ParseOutPointError {
|
impl ::std::error::Error for ParseOutPointError {
|
||||||
fn description(&self) -> &str {
|
fn description(&self) -> &str {
|
||||||
match *self {
|
"description() is deprecated; use Display"
|
||||||
ParseOutPointError::Txid(_) => "TXID parse error",
|
|
||||||
ParseOutPointError::Vout(_) => "vout parse error",
|
|
||||||
ParseOutPointError::Format => "outpoint format error",
|
|
||||||
ParseOutPointError::TooLong => "size error",
|
|
||||||
ParseOutPointError::VoutNotCanonical => "vout canonical error",
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cause(&self) -> Option<&::std::error::Error> {
|
fn cause(&self) -> Option<&::std::error::Error> {
|
||||||
|
|
|
@ -109,6 +109,7 @@ impl fmt::Display for Error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
impl error::Error for Error {
|
impl error::Error for Error {
|
||||||
fn cause(&self) -> Option<&error::Error> {
|
fn cause(&self) -> Option<&error::Error> {
|
||||||
match *self {
|
match *self {
|
||||||
|
@ -127,7 +128,7 @@ impl error::Error for Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn description(&self) -> &str {
|
fn description(&self) -> &str {
|
||||||
"Bitcoin encoding error"
|
"description() is deprecated; use Display"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,8 @@ impl fmt::Display for Error {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
Error::Io(ref e) => fmt::Display::fmt(e, f),
|
Error::Io(ref e) => fmt::Display::fmt(e, f),
|
||||||
Error::SocketMutexPoisoned | Error::SocketNotConnectedToPeer => f.write_str(error::Error::description(self)),
|
Error::SocketMutexPoisoned => f.write_str("socket mutex was poisoned"),
|
||||||
|
Error::SocketNotConnectedToPeer => f.write_str("not connected to peer"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,13 +60,10 @@ impl From<io::Error> for Error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
impl error::Error for Error {
|
impl error::Error for Error {
|
||||||
fn description(&self) -> &str {
|
fn description(&self) -> &str {
|
||||||
match *self {
|
"description() is deprecated; use Display"
|
||||||
Error::Io(ref e) => e.description(),
|
|
||||||
Error::SocketMutexPoisoned => "socket mutex was poisoned",
|
|
||||||
Error::SocketNotConnectedToPeer => "not connected to peer",
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cause(&self) -> Option<&error::Error> {
|
fn cause(&self) -> Option<&error::Error> {
|
||||||
|
|
|
@ -91,6 +91,7 @@ impl fmt::Display for Error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
impl ::std::error::Error for Error {
|
impl ::std::error::Error for Error {
|
||||||
fn cause(&self) -> Option<&::std::error::Error> {
|
fn cause(&self) -> Option<&::std::error::Error> {
|
||||||
match *self {
|
match *self {
|
||||||
|
@ -100,8 +101,8 @@ impl ::std::error::Error for Error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn description(&self) -> &'static str {
|
fn description(&self) -> &str {
|
||||||
"std::error::Error::description is deprecated"
|
"description() is deprecated; use Display"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,30 +102,22 @@ pub enum ParseAmountError {
|
||||||
|
|
||||||
impl fmt::Display for ParseAmountError {
|
impl fmt::Display for ParseAmountError {
|
||||||
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 {
|
||||||
ParseAmountError::InvalidCharacter(c) => write!(f, "{}: {}", desc, c),
|
ParseAmountError::Negative => f.write_str("amount is negative"),
|
||||||
ParseAmountError::UnknownDenomination(ref d) => write!(f, "{}: {}", desc, d),
|
ParseAmountError::TooBig => f.write_str("amount is too big"),
|
||||||
_ => f.write_str(desc),
|
ParseAmountError::TooPrecise => f.write_str("amount has a too high precision"),
|
||||||
|
ParseAmountError::InvalidFormat => f.write_str("invalid number format"),
|
||||||
|
ParseAmountError::InputTooLarge => f.write_str("input string was too large"),
|
||||||
|
ParseAmountError::InvalidCharacter(c) => write!(f, "invalid character in input: {}", c),
|
||||||
|
ParseAmountError::UnknownDenomination(ref d) => write!(f, "unknown denomination: {}",d),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
impl error::Error for ParseAmountError {
|
impl error::Error for ParseAmountError {
|
||||||
fn cause(&self) -> Option<&error::Error> {
|
fn description(&self) -> &str {
|
||||||
None
|
"description() is deprecated; use Display"
|
||||||
}
|
|
||||||
|
|
||||||
fn description(&self) -> &'static str {
|
|
||||||
match *self {
|
|
||||||
ParseAmountError::Negative => "amount is negative",
|
|
||||||
ParseAmountError::TooBig => "amount is too big",
|
|
||||||
ParseAmountError::TooPrecise => "amount has a too high precision",
|
|
||||||
ParseAmountError::InvalidFormat => "invalid number format",
|
|
||||||
ParseAmountError::InputTooLarge => "input string was too large",
|
|
||||||
ParseAmountError::InvalidCharacter(_) => "invalid character in input",
|
|
||||||
ParseAmountError::UnknownDenomination(_) => "unknown denomination",
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,17 +52,10 @@ impl fmt::Display for Error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
impl error::Error for Error {
|
impl error::Error for Error {
|
||||||
fn cause(&self) -> Option<&error::Error> { None }
|
fn description(&self) -> &str {
|
||||||
fn description(&self) -> &'static str {
|
"description() is deprecated; use Display"
|
||||||
match *self {
|
|
||||||
Error::BadByte(_) => "invalid b58 character",
|
|
||||||
Error::BadChecksum(_, _) => "invalid b58ck checksum",
|
|
||||||
Error::InvalidLength(_) => "invalid length for b58 type",
|
|
||||||
Error::InvalidVersion(_) => "invalid version for b58 type",
|
|
||||||
Error::TooShort(_) => "b58ck data less than 4 bytes",
|
|
||||||
Error::Other(_) => "unknown b58 error"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,12 +73,10 @@ pub enum Error {
|
||||||
Io(io::Error),
|
Io(io::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
impl error::Error for Error {
|
impl error::Error for Error {
|
||||||
fn description(&self) -> &str {
|
fn description(&self) -> &str {
|
||||||
match *self {
|
"description() is deprecated; use Display"
|
||||||
Error::UtxoMissing(_) => "unresolved UTXO",
|
|
||||||
Error::Io(_) => "IO Error"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -391,14 +391,7 @@ impl error::Error for Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn description(&self) -> &str {
|
fn description(&self) -> &str {
|
||||||
match *self {
|
"description() is deprecated; use Display"
|
||||||
Error::CannotDeriveFromHardenedKey => "cannot derive hardened key from public key",
|
|
||||||
Error::Ecdsa(ref e) => error::Error::description(e),
|
|
||||||
Error::InvalidChildNumber(_) => "child number is invalid",
|
|
||||||
Error::RngError(_) => "rng error",
|
|
||||||
Error::InvalidChildNumberFormat => "invalid child number format",
|
|
||||||
Error::InvalidDerivationPathFormat => "invalid derivation path format",
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,7 @@ impl fmt::Display for Error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
impl error::Error for Error {
|
impl error::Error for Error {
|
||||||
fn cause(&self) -> Option<&error::Error> {
|
fn cause(&self) -> Option<&error::Error> {
|
||||||
match *self {
|
match *self {
|
||||||
|
@ -78,16 +79,8 @@ impl error::Error for Error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn description(&self) -> &'static str {
|
fn description(&self) -> &str {
|
||||||
match *self {
|
"description() is deprecated; use Display"
|
||||||
Error::Secp(_) => "libsecp256k1 error",
|
|
||||||
Error::Script(_) => "script error",
|
|
||||||
Error::UncompressedKey => "encountered uncompressed secp public key",
|
|
||||||
Error::ExpectedKey => "expected key when deserializing script",
|
|
||||||
Error::ExpectedChecksig => "expected OP_*CHECKSIG* when deserializing script",
|
|
||||||
Error::TooFewKeys(_) => "too few keys for template",
|
|
||||||
Error::TooManyKeys(_) => "too many keys for template"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ impl error::Error for Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn description(&self) -> &str {
|
fn description(&self) -> &str {
|
||||||
"Bitcoin key error"
|
"description() is deprecated; use Display"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,11 +77,13 @@ impl fmt::Display for Error {
|
||||||
match *self {
|
match *self {
|
||||||
Error::Encode(ref e) => fmt::Display::fmt(e, f),
|
Error::Encode(ref e) => fmt::Display::fmt(e, f),
|
||||||
Error::Network(ref e) => fmt::Display::fmt(e, f),
|
Error::Network(ref e) => fmt::Display::fmt(e, f),
|
||||||
Error::BlockBadProofOfWork | Error::BlockBadTarget => f.write_str(error::Error::description(self)),
|
Error::BlockBadProofOfWork => f.write_str("block target correct but not attained"),
|
||||||
|
Error::BlockBadTarget => f.write_str("block target incorrect"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
impl error::Error for Error {
|
impl error::Error for Error {
|
||||||
fn cause(&self) -> Option<&error::Error> {
|
fn cause(&self) -> Option<&error::Error> {
|
||||||
match *self {
|
match *self {
|
||||||
|
@ -92,12 +94,7 @@ impl error::Error for Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn description(&self) -> &str {
|
fn description(&self) -> &str {
|
||||||
match *self {
|
"description() is deprecated; use Display"
|
||||||
Error::Encode(ref e) => e.description(),
|
|
||||||
Error::Network(ref e) => e.description(),
|
|
||||||
Error::BlockBadProofOfWork => "block target correct but not attained",
|
|
||||||
Error::BlockBadTarget => "block target incorrect",
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,35 +53,25 @@ 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 {
|
||||||
match *self {
|
match *self {
|
||||||
Error::InvalidKey(ref rkey) => write!(f, "{}: {}", error::Error::description(self), rkey),
|
Error::InvalidKey(ref rkey) => write!(f, "invalid key: {}", rkey),
|
||||||
Error::DuplicateKey(ref rkey) => write!(f, "{}: {}", error::Error::description(self), rkey),
|
Error::DuplicateKey(ref rkey) => write!(f, "duplicate key: {}", rkey),
|
||||||
Error::UnexpectedUnsignedTx { expected: ref e, actual: ref a } => write!(f, "{}: expected {}, actual {}", error::Error::description(self), 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, "{}: {}", error::Error::description(self), sht),
|
Error::NonStandardSigHashType(ref sht) => write!(f, "non-standard sighash type: {}", sht),
|
||||||
Error::InvalidMagic
|
Error::InvalidMagic => f.write_str("invalid magic"),
|
||||||
| Error::InvalidSeparator
|
Error::InvalidSeparator => f.write_str("invalid separator"),
|
||||||
| Error::UnsignedTxHasScriptSigs
|
Error::UnsignedTxHasScriptSigs => f.write_str("the unsigned transaction has script sigs"),
|
||||||
| Error::UnsignedTxHasScriptWitnesses
|
Error::UnsignedTxHasScriptWitnesses => f.write_str("the unsigned transaction has script witnesses"),
|
||||||
| Error::MustHaveUnsignedTx
|
Error::MustHaveUnsignedTx => {
|
||||||
| Error::NoMorePairs => f.write_str(error::Error::description(self))
|
f.write_str("partially signed transactions must have an unsigned transaction")
|
||||||
|
}
|
||||||
|
Error::NoMorePairs => f.write_str("no more key-value pairs for this psbt map"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
impl error::Error for Error {
|
impl error::Error for Error {
|
||||||
fn description(&self) -> &str {
|
fn description(&self) -> &str {
|
||||||
match *self {
|
"description() is deprecated; use Display"
|
||||||
Error::InvalidMagic => "invalid magic",
|
|
||||||
Error::InvalidSeparator => "invalid separator",
|
|
||||||
Error::InvalidKey(..) => "invalid key",
|
|
||||||
Error::DuplicateKey(..) => "duplicate key",
|
|
||||||
Error::UnsignedTxHasScriptSigs => "the unsigned transaction has script sigs",
|
|
||||||
Error::UnsignedTxHasScriptWitnesses => "the unsigned transaction has script witnesses",
|
|
||||||
Error::MustHaveUnsignedTx => {
|
|
||||||
"partially signed transactions must have an unsigned transaction"
|
|
||||||
}
|
|
||||||
Error::NoMorePairs => "no more key-value pairs for this psbt map",
|
|
||||||
Error::UnexpectedUnsignedTx { .. } => "different unsigned transaction",
|
|
||||||
Error::NonStandardSigHashType(..) => "non-standard sighash type",
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue