Skip to content

Commit

Permalink
Error handling refactor (#446)
Browse files Browse the repository at this point in the history
* refactor: error handling

Signed-off-by: Jingfu Wang <[email protected]>

* refactor: update message

Signed-off-by: Jingfu Wang <[email protected]>

Signed-off-by: Jingfu Wang <[email protected]>
  • Loading branch information
GeekArthur authored Sep 20, 2022
1 parent 33738c2 commit 1cc6016
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion constructor/dsl/dsl.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func Parse(ctx context.Context, file string) ([]*job.Workflow, *Error) {
}
defer func() {
if err := f.Close(); err != nil {
log.Printf("%s: could not close %s\n", err.Error(), cleanedPath)
log.Printf("could not close %s: %s\n", cleanedPath, err.Error())
}
}()

Expand Down
4 changes: 2 additions & 2 deletions fetcher/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ func tryAgain(fetchMsg string, thisBackoff *Backoff, err *Error) *Error {

thisBackoff.attempts++
log.Printf(
"%s: retrying fetch for %s after %fs (prior attempts: %d)\n",
errMessage,
"retrying fetch for %s after %fs (prior attempts: %d): %s\n",
fetchMsg,
nextBackoff.Seconds(),
thisBackoff.attempts,
errMessage,
)
time.Sleep(nextBackoff)

Expand Down
4 changes: 2 additions & 2 deletions parser/intent.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ func (p *Parser) ExpectedOperations(

if len(failedMatches) > 0 {
errString += fmt.Sprintf(
"%s: found matching ops with unsuccessful status %s",
errString,
"found matching ops with unsuccessful status %s: %s",
types.PrettyPrintStruct(failedMatches),
errString,
)
}

Expand Down
6 changes: 3 additions & 3 deletions reconciler/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (r *Reconciler) wrappedActiveEnqueue(
change.Currency,
BacklogFull,
); err != nil {
log.Printf("%s: reconciliation skipped handling failed\n", err.Error())
log.Printf("reconciliation skipped handling failed: %s\n", err.Error())
}
}
}
Expand All @@ -106,9 +106,9 @@ func (r *Reconciler) wrappedInactiveEnqueue(
) {
if err := r.inactiveAccountQueue(true, accountCurrency, liveBlock, false); err != nil {
log.Printf(
"%s: unable to queue account %s",
err.Error(),
"unable to queue account %s: %s",
types.PrintStruct(accountCurrency),
err.Error(),
)
}
}
Expand Down
5 changes: 4 additions & 1 deletion storage/modules/balance_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -884,8 +884,11 @@ func (b *BalanceStorage) UpdateBalance(

if bigNewVal.Sign() == -1 {
return false, fmt.Errorf(
"%s is invalid: %w",
"account balance %s of currency %s for account %s at block %s is invalid: %w",
newVal,
types.PrintStruct(change.Currency),
types.PrintStruct(change.Account),
types.PrintStruct(change.Block),
storageErrs.ErrNegativeBalance,
)
}
Expand Down
4 changes: 2 additions & 2 deletions storage/modules/broadcast_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,9 +443,9 @@ func (b *BroadcastStorage) performBroadcast(
if err != nil {
// Don't error on broadcast failure, retries will automatically be handled.
log.Printf(
"%s: unable to broadcast transaction %s",
err.Error(),
"unable to broadcast transaction %s: %s",
broadcast.TransactionIdentifier.Hash,
err.Error(),
)

return nil
Expand Down

0 comments on commit 1cc6016

Please sign in to comment.