diff --git a/crates/chain-orchestrator/src/lib.rs b/crates/chain-orchestrator/src/lib.rs index 5605395b..a9b7c014 100644 --- a/crates/chain-orchestrator/src/lib.rs +++ b/crates/chain-orchestrator/src/lib.rs @@ -650,7 +650,7 @@ impl< .get_block_by_number(block_number.into()) .full() .await? - .expect("L2 head block must exist") + .ok_or(ChainOrchestratorError::L2BlockNotFoundInL2Client(block_number))? .header .hash_slow(); @@ -1015,7 +1015,9 @@ impl< .get_block_by_number(current_head_block_number.into()) .full() .await? - .expect("current head block must exist"); + .ok_or(ChainOrchestratorError::L2BlockNotFoundInL2Client( + current_head_block_number, + ))?; // If the timestamp of the received block is less than or equal to the current head, // we ignore it. @@ -1077,7 +1079,7 @@ impl< .get_block_by_number(header.number.into()) .full() .await? - .expect("block must exist") + .ok_or(ChainOrchestratorError::L2BlockNotFoundInL2Client(header.number))? .into_consensus() .map_transactions(|tx| tx.inner.into_inner());