Skip to content

Commit

Permalink
fix(opt8n): handle errors
Browse files Browse the repository at this point in the history
  • Loading branch information
refcell committed Jul 29, 2024
1 parent b37680d commit faec593
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions bin/opt8n/src/opt8n.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ impl Opt8n {
output_file: PathBuf,
genesis: Option<PathBuf>,
) -> Result<Self> {
let genesis = genesis.as_ref().map(|path| {
serde_json::from_reader(File::open(path).expect("TODO: handle error Invalid path"))
.expect("TODO: handle error Invalid genesis")
});
let genesis = if let Some(genesis) = genesis.as_ref() {
serde_json::from_reader(File::open(genesis)?)?
} else {
None
};

let node_config = node_config
.unwrap_or_default()
Expand Down Expand Up @@ -106,7 +107,7 @@ impl Opt8n {
// Mine the block and generate the execution fixture
opt8n.mine_block().await;

let block = new_blocks.next().await.expect("TODO: handle error");
let block = new_blocks.next().await.ok_or(eyre!("No new block"))?;
if let Some(block) = opt8n.eth_api.backend.get_block_by_hash(block.hash) {
opt8n.generate_execution_fixture(block).await?;
}
Expand Down Expand Up @@ -147,7 +148,7 @@ impl Opt8n {
.eth_api
.txpool_content()
.await
.expect("TODO: handle error")
.expect("Failed to get txpool content")
.pending
.len();

Expand Down Expand Up @@ -207,7 +208,7 @@ impl Opt8n {
self.node_handle.http_provider(),
BlockId::from(block.header.number - 1),
)
.expect("Could not create AlloyDB"),
.ok_or_else(|| eyre!("Failed to create AlloyDB"))?,
);

let block_env = BlockEnv {
Expand Down

0 comments on commit faec593

Please sign in to comment.