Skip to content

Commit 1c18a84

Browse files
committed
Simplify error management
1 parent 9100bda commit 1c18a84

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

mithril-common/src/cardano_transaction_parser.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,12 @@ impl CardanoTransactionParser {
120120
CardanoTransactionParser::cardano_blocks_reader(immutable_file)?;
121121

122122
let mut blocks = Vec::new();
123-
for block in cardano_blocks_reader {
124-
let block = block.map_err(|e| {
125-
anyhow!(e).context(format!(
123+
for parsed_block in cardano_blocks_reader {
124+
let block = parsed_block.with_context(|| {
125+
format!(
126126
"Error while reading block in immutable file: '{:?}'",
127127
immutable_file.path
128-
))
128+
)
129129
})?;
130130
blocks.push(CardanoTransactionParser::convert_to_block(
131131
&block,
@@ -136,11 +136,11 @@ impl CardanoTransactionParser {
136136
}
137137

138138
fn convert_to_block(block: &[u8], immutable_file: &ImmutableFile) -> StdResult<Block> {
139-
let multi_era_block = MultiEraBlock::decode(block).map_err(|e| {
140-
anyhow!(e).context(format!(
139+
let multi_era_block = MultiEraBlock::decode(block).with_context(|| {
140+
format!(
141141
"Error while decoding block in immutable file: '{:?}'",
142142
immutable_file.path
143-
))
143+
)
144144
})?;
145145

146146
Block::try_convert(multi_era_block, immutable_file.number).with_context(|| {

0 commit comments

Comments
 (0)