lint: fix remaining errcheck for Write, Fprintf, Rollback, Commit
- Use lint.Write for unchecked w.Write in handlerJSONPost/Put, report - Use lint.Fprintf for fmt.Fprintf in twilio handlers - Use lint.LogOnErrRollback for deferred Rollbacks in compliance, lead, note - Check errors from txn.Commit in lead, note - Use lint.LogOnErrCtx for addError calls in flyover
This commit is contained in:
parent
679d12b48f
commit
808e172221
7 changed files with 36 additions and 18 deletions
|
|
@ -9,6 +9,7 @@ import (
|
|||
"github.com/Gleipnir-Technology/bob/dialect/psql"
|
||||
"github.com/Gleipnir-Technology/bob/dialect/psql/sm"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/lint"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db/gen/nidus-sync/public/model"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db/models"
|
||||
query "github.com/Gleipnir-Technology/nidus-sync/db/query/public"
|
||||
|
|
@ -23,13 +24,15 @@ func LeadCreate(ctx context.Context, user User, signal_id int32, site_id int32,
|
|||
if err != nil {
|
||||
return model.Lead{}, fmt.Errorf("start transaction: %w", err)
|
||||
}
|
||||
defer txn.Rollback(ctx)
|
||||
defer lint.LogOnErrRollback(txn.Rollback, ctx, "rollback")
|
||||
|
||||
lead, err := leadCreate(ctx, txn, user, signal_id, site_id, pool_location)
|
||||
if err != nil {
|
||||
return model.Lead{}, fmt.Errorf("inner leadcreate: %w", err)
|
||||
}
|
||||
txn.Commit(ctx)
|
||||
if err := txn.Commit(ctx); err != nil {
|
||||
return model.Lead{}, fmt.Errorf("commit: %w", err)
|
||||
}
|
||||
return lead, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue