Skip to content

Commit

Permalink
improve errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Wollac committed Jan 11, 2024
1 parent b8bbceb commit d5aac96
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion host/src/bin/op-derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ async fn main() -> Result<()> {
let output_mem = DeriveMachine::new(&OPTIMISM_CHAIN_SPEC, derive_input.clone())
.context("Could not create derive machine")?
.derive()
.unwrap();
.context("could not derive")?;
assert_eq!(output, output_mem);
}

Expand Down
12 changes: 9 additions & 3 deletions lib/src/optimism/batcher_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

use std::collections::HashMap;

use anyhow::{ensure, Result};
use anyhow::{ensure, Context, Result};
use serde::{Deserialize, Serialize};
use zeth_primitives::{
block::Header,
Expand Down Expand Up @@ -99,7 +99,10 @@ impl BatcherDb for MemDb {
}

fn get_op_block_header(&mut self, block_no: u64) -> Result<Header> {
let op_block = self.op_block_header.remove(&block_no).unwrap();
let op_block = self
.op_block_header
.remove(&block_no)
.context("not or no longer in db")?;
assert_eq!(block_no, op_block.number);

Ok(op_block)
Expand Down Expand Up @@ -156,7 +159,10 @@ impl BatcherDb for MemDb {
}

fn get_eth_block_header(&mut self, block_no: u64) -> Result<Header> {
let eth_block = self.eth_block_header.remove(&block_no).unwrap();
let eth_block = self
.eth_block_header
.remove(&block_no)
.context("not or no longer in db")?;
assert_eq!(block_no, eth_block.number);

Ok(eth_block)
Expand Down

0 comments on commit d5aac96

Please sign in to comment.