Merge rust-bitcoin/rust-bitcoin#3864: Update for ParsePublicKeyError Display and Error impl

b11ace359a Fix up ParsePublickeyError (Innocent Onyemaenu)

Pull request description:

  Resolves #3835

  In #945fcd09 we forgot to Update impl for ParsePublicKeyError Display and Error traits

ACKs for top commit:
  tcharding:
    ACK b11ace359a
  apoelstra:
    ACK b11ace359a52d9137b8fe5919d9825d61e3e9fad; successfully ran local tests; thanks!!

Tree-SHA512: 5c4e5e113605bc5b9c3c0d2ca65a0fdae80726a0f2f791255cc1d6567812a9132ff4f5bd8f30276fef916469d5fd29f6d72ddf4adb6340e52f4e0198ac4fb371
This commit is contained in:
merge-script 2025-01-16 01:37:12 +00:00
commit 6bc12e9363
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
1 changed files with 7 additions and 6 deletions

View File

@ -1034,9 +1034,9 @@ impl From<Infallible> for ParsePublicKeyError {
impl fmt::Display for ParsePublicKeyError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use ParsePublicKeyError::*;
match self {
Encoding(e) => write_err!(f, "string error"; e),
InvalidChar(char) => write!(f, "hex error {}", char),
match *self {
Encoding(ref e) => write_err!(f, "string error"; e),
InvalidChar(ref e) => write_err!(f, "hex decoding"; e),
InvalidHexLength(got) =>
write!(f, "pubkey string should be 66 or 130 digits long, got: {}", got),
}
@ -1048,9 +1048,10 @@ impl std::error::Error for ParsePublicKeyError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
use ParsePublicKeyError::*;
match self {
Encoding(e) => Some(e),
InvalidChar(_) | InvalidHexLength(_) => None,
match *self {
Encoding(ref e) => Some(e),
InvalidChar(ref e) => Some(e),
InvalidHexLength(_) => None,
}
}
}