Skip to content

Commit 2edf7a0

Browse files
authored
add error handling for missing L2 block (#430)
1 parent 328b9e9 commit 2edf7a0

File tree

1 file changed

+5
-3
lines changed
  • crates/chain-orchestrator/src

1 file changed

+5
-3
lines changed

crates/chain-orchestrator/src/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ impl<
650650
.get_block_by_number(block_number.into())
651651
.full()
652652
.await?
653-
.expect("L2 head block must exist")
653+
.ok_or(ChainOrchestratorError::L2BlockNotFoundInL2Client(block_number))?
654654
.header
655655
.hash_slow();
656656

@@ -1015,7 +1015,9 @@ impl<
10151015
.get_block_by_number(current_head_block_number.into())
10161016
.full()
10171017
.await?
1018-
.expect("current head block must exist");
1018+
.ok_or(ChainOrchestratorError::L2BlockNotFoundInL2Client(
1019+
current_head_block_number,
1020+
))?;
10191021

10201022
// If the timestamp of the received block is less than or equal to the current head,
10211023
// we ignore it.
@@ -1077,7 +1079,7 @@ impl<
10771079
.get_block_by_number(header.number.into())
10781080
.full()
10791081
.await?
1080-
.expect("block must exist")
1082+
.ok_or(ChainOrchestratorError::L2BlockNotFoundInL2Client(header.number))?
10811083
.into_consensus()
10821084
.map_transactions(|tx| tx.inner.into_inner());
10831085

0 commit comments

Comments
 (0)