@@ -306,7 +306,7 @@ where
306306 // Note: We can safely unwrap the subgraph ptr here, because
307307 // if it was `None`, `is_on_main_chain` would be true.
308308 let from = subgraph_ptr. unwrap ( ) ;
309- let parent = self . parent_ptr ( & from) . await ?;
309+ let parent = self . parent_ptr ( & from, "is_on_main_chain" ) . await ?;
310310
311311 return Ok ( ReconciliationStep :: Revert ( parent) ) ;
312312 }
@@ -441,7 +441,7 @@ where
441441 . await ?;
442442 Ok ( ReconciliationStep :: ProcessDescendantBlocks ( vec ! [ block] , 1 ) )
443443 } else {
444- let parent = self . parent_ptr ( & subgraph_ptr) . await ?;
444+ let parent = self . parent_ptr ( & subgraph_ptr, "nonfinal" ) . await ?;
445445
446446 // The subgraph ptr is not on the main chain.
447447 // We will need to step back (possibly repeatedly) one block at a time
@@ -453,12 +453,11 @@ where
453453 }
454454 }
455455
456- async fn parent_ptr ( & self , block_ptr : & BlockPtr ) -> Result < BlockPtr , Error > {
457- let ptr = self
458- . adapter
459- . parent_ptr ( block_ptr)
460- . await ?
461- . expect ( "genesis block can't be reverted" ) ;
456+ async fn parent_ptr ( & self , block_ptr : & BlockPtr , reason : & str ) -> Result < BlockPtr , Error > {
457+ let ptr =
458+ self . adapter . parent_ptr ( block_ptr) . await ?. ok_or_else ( || {
459+ anyhow ! ( "Failed to get parent pointer for {block_ptr} ({reason})" )
460+ } ) ?;
462461
463462 Ok ( ptr)
464463 }
0 commit comments