Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Commit

Permalink
better messages for unwraps and clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lostman committed Sep 25, 2023
1 parent 0c6582b commit 283183b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions packages/fuel-indexer/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ pub fn run_executor<T: 'static + Executor + Send + Sync>(
let enable_block_store = config.enable_block_store;

async move {
let mut conn = pool.acquire().await.expect(&format!(
"Indexer({indexer_uid}) was unable to acquire a database connection."
));
let mut conn = pool.acquire().await.unwrap_or_else(|_| {
panic!("Indexer({indexer_uid}) was unable to acquire a database connection.")
});

// If we reach an issue that continues to fail, we'll retry a few times before giving up, as
// we don't want to quit on the first error. But also don't want to waste CPU.
Expand All @@ -134,9 +134,9 @@ pub fn run_executor<T: 'static + Executor + Send + Sync>(

let mut start_block = crate::get_start_block(&mut conn, executor.manifest())
.await
.expect(&format!(
"Indexer({indexer_uid}) was unable to determine the start block"
));
.unwrap_or_else(|_| {
panic!("Indexer({indexer_uid}) was unable to determine the start block")
});

// Where should we initially start when fetching blocks from the client?
let mut cursor = Some((start_block - 1).to_string());
Expand Down
8 changes: 4 additions & 4 deletions packages/fuel-indexer/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,16 +406,16 @@ pub(crate) async fn create_block_sync_task(
config: IndexerConfig,
pool: IndexerConnectionPool,
) {
let task_id = "Block Sync";

let mut conn = pool.acquire().await.unwrap();

let last_height = queries::last_block_height_for_stored_blocks(&mut conn)
.await
.unwrap();
.unwrap_or_else(|_| panic!("{task_id} was unable to determine the last block height for stored blocks."));

let mut cursor = Some(last_height.to_string());

let task_id = "Block Sync";

info!("{task_id}: starting from Block#{}", last_height + 1);

let client =
Expand Down Expand Up @@ -464,7 +464,7 @@ pub(crate) async fn create_block_sync_task(
// `save_blockdata` succeeds, all is well.
fuel_indexer_database::queries::save_block_data(&mut conn, &block_info)
.await
.unwrap();
.unwrap_or_else(|_| panic!("{task_id} was unable to save block data."));

cursor = next_cursor;
}
Expand Down

0 comments on commit 283183b

Please sign in to comment.