Skip to content

Commit

Permalink
made sure that alias error reporting is less spammy
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderStorm committed Jan 3, 2025
1 parent f8ab74a commit 1e76211
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions server/src/setup/database/alias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,27 @@ pub async fn load_all_to_db(
aliases: LimitedVec<Alias>,
tx: &mut sqlx::Transaction<'_, sqlx::Postgres>,
) -> anyhow::Result<()> {
let mut total_errors_cnt = 0_usize;
for task in aliases {
if let Err(e) = task.clone().store(tx).await {
error!(
key = task.key,
type = task.r#type,
visible_id = task.visible_id,
error = ?e,
"Could not store alias",
)
total_errors_cnt += 1;
if total_errors_cnt < 3 {
error!(
key = task.key,
type = task.r#type,
visible_id = task.visible_id,
error = ?e,
"Could not store alias (sample {total_errors_cnt}/3)",
)
}
}
}
if total_errors_cnt > 3 {
error!(
total_errors_cnt,
"there were unreported erros in storing aliases"
);
}

Ok(())
}

0 comments on commit 1e76211

Please sign in to comment.