Skip to content

Commit 9318965

Browse files
committed
audit(coderabbit): add additional error handle for query block prod
1 parent 310d397 commit 9318965

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

pkgs/database/timescaledb/query_block.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,10 @@ func (t *TimescaleDb) GetAvgBlockProdTime(ctx context.Context, chainName string)
311311
var heightDiff uint64
312312
var tEnd, tStart time.Time
313313
if err := row.Scan(&heightDiff, &tEnd, &tStart); err != nil {
314-
return 0, fmt.Errorf("not enough block data to compute average block time for chain %q", chainName)
314+
if errors.Is(err, pgx.ErrNoRows) {
315+
return 0, fmt.Errorf("not enough block data to compute average block time for chain %q", chainName)
316+
}
317+
return 0, fmt.Errorf("querying average block time for chain %q: %w", chainName, err)
315318
}
316319
if heightDiff == 0 {
317320
return 0, fmt.Errorf("not enough block data to compute average block time for chain %q", chainName)

0 commit comments

Comments
 (0)