HomePhabricator

[CHRONIK][WEB][MODULES] Updated thiserror from 1.0 -> 2.0.3 in Cargo.toml

Description

[CHRONIK][WEB][MODULES] Updated thiserror from 1.0 -> 2.0.3 in Cargo.toml

Summary:
With the new thiserror version (2.0.3), we can no longer rely on unnamed placeholders {}; we must either pass named arguments (e.g., {named_argument}) or use explicit positional placeholders ({0}, {1}) for clarity and correctness.

old code:

`#[error(
     "Bad usage of merge: Unknown prefix {0:02x}, expected C or T: {}",
     hex::encode(.1),
 )]
 UnknownOperandPrefix(u8, Vec<u8>),`

The (.1) in hex::encode(.1) is an ambiguous reference because thiserror is expecting named arguments
and doesn't understand that .1 refers to the second element of the tuple. Therefore, I have named the arguments, so that
its clear to the macro what each argument corresponds to.

new code:

`#[error(
    "Bad usage of merge: Unknown prefix {prefix:02x},
    expected C or T: {encoded}",
    prefix = .0,
    encoded = hex::encode(.1),
)]
UnknownOperandPrefix(u8, Vec<u8>), `

Here, we have made it explicit what .1 refers to, by passing it into a variable and passing it in as an argument into the placeholders.

Test Plan: ninja check-functional

Reviewers: O1 Bitcoin ABC, #bitcoin_abc, tobias_ruck

Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, tobias_ruck

Subscribers: tobias_ruck

Differential Revision: https://reviews.bitcoinabc.org/D17267

Details

Provenance
hazzarustAuthored on Sat, Nov 30, 20:38
hazzarustPushed on Mon, Dec 2, 22:58
Reviewer
Restricted Owners Package
Differential Revision
D17267: [CHRONIK][WEB][MODULES] Updated thiserror from 1.0 -> 2.0.3 in Cargo.toml
Parents
rABC290f1908775f: [mock-chronik-client] Add MockAgora to stub ts declaration
Branches
Unknown
Tags
Unknown