Skip to content

Commit

Permalink
fix: error handling issues (#363)
Browse files Browse the repository at this point in the history
Signed-off-by: Jingfu Wang <[email protected]>

Signed-off-by: Jingfu Wang <[email protected]>
  • Loading branch information
GeekArthur authored Sep 19, 2022
1 parent 7bb7304 commit 6dd4f30
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 5 additions & 1 deletion pkg/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,11 @@ func (l *Logger) RemoveBlockStream(
)
fmt.Print(blockString)
_, err = f.WriteString(blockString)
return fmt.Errorf("failed to write block string %s: %w", blockString, err)
if err != nil {
return fmt.Errorf("failed to write block string %s: %w", blockString, err)
}

return nil
}

// TransactionStream writes the next processed block's transactions
Expand Down
10 changes: 8 additions & 2 deletions pkg/processor/balance_storage_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ func (h *BalanceStorageHandler) AccountsReconciled(
modules.ReconciledAccounts,
big.NewInt(int64(count)),
)
return fmt.Errorf("failed to update the total accounts reconciled by count: %w", err)
if err != nil {
return fmt.Errorf("failed to update the total accounts reconciled by count: %w", err)
}
return nil
}

// AccountsSeen updates the total accounts seen by count.
Expand All @@ -140,5 +143,8 @@ func (h *BalanceStorageHandler) AccountsSeen(
modules.SeenAccounts,
big.NewInt(int64(count)),
)
return fmt.Errorf("failed to update the total accounts seen by count: %w", err)
if err != nil {
return fmt.Errorf("failed to update the total accounts seen by count: %w", err)
}
return nil
}

0 comments on commit 6dd4f30

Please sign in to comment.