Skip to content

Commit

Permalink
fix: Strong Error Typing (#187)
Browse files Browse the repository at this point in the history
* fix: error types

* fix: error types

* fix: channel error typing
  • Loading branch information
refcell authored May 29, 2024
1 parent 8cf2095 commit f35d69c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion crates/derive/src/types/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ impl Channel {
(0..=self.last_frame_number).try_for_each(|i| {
let frame = self.inputs.get(&i).ok_or_else(|| anyhow!("Frame not found"))?;
data.extend_from_slice(&frame.data);
Ok(())
Ok::<(), anyhow::Error>(())
})?;
Ok(data.into())
}
Expand Down
2 changes: 1 addition & 1 deletion crates/primitives/src/block_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl L1BlockInfoTx {
let scalar = system_config.l1_fee_scalar.to_be_bytes::<32>();
let blob_base_fee_scalar = (scalar[0] == L1_SCALAR_ECOTONE)
.then(|| {
Ok(u32::from_be_bytes(
Ok::<u32, anyhow::Error>(u32::from_be_bytes(
scalar[24..28]
.try_into()
.map_err(|_| anyhow!("Failed to parse L1 blob base fee scalar"))?,
Expand Down
8 changes: 5 additions & 3 deletions crates/primitives/src/system_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,14 @@ impl SystemConfig {
!topics.is_empty() &&
topics[0] == CONFIG_UPDATE_TOPIC
{
self.process_config_update_log(log, rollup_config, l1_time)?;
if let Err(e) = self.process_config_update_log(log, rollup_config, l1_time) {
anyhow::bail!("Failed to process config update log: {:?}", e);
}
}
Ok(())
Ok::<(), anyhow::Error>(())
})?;
}
Ok(())
Ok::<(), anyhow::Error>(())
}

/// Decodes an EVM log entry emitted by the system config contract and applies it as a
Expand Down

0 comments on commit f35d69c

Please sign in to comment.