Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

db err check #24

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ func (c *Connection) GetTonWalletsAddresses(
}
res = append(res, a)
}
if rows.Err() != nil {
return nil, rows.Err()
}
return res, nil
}

Expand Down Expand Up @@ -258,6 +261,9 @@ func (c *Connection) GetJettonOwnersAddresses(
}
res = append(res, ow)
}
if rows.Err() != nil {
return nil, rows.Err()
}
return res, nil
}

Expand All @@ -284,7 +290,9 @@ func (c *Connection) LoadAddressBook(ctx context.Context) error {
}
res[addr] = core.AddressInfo{Type: t, Owner: nil, UserID: userID}
}

if rows.Err() != nil {
return rows.Err()
}
rows, err = c.client.Query(ctx, `
SELECT jw.address, jw.type, tw.address, jw.user_id
FROM payments.jetton_wallets jw
Expand All @@ -302,6 +310,9 @@ func (c *Connection) LoadAddressBook(ctx context.Context) error {
}
res[addr] = core.AddressInfo{Type: t, Owner: &owner, UserID: userID}
}
if rows.Err() != nil {
return rows.Err()
}

c.addressBook.addresses = res
log.Info("Address book loaded")
Expand Down Expand Up @@ -491,6 +502,9 @@ func (c *Connection) GetExternalWithdrawalTasks(ctx context.Context, limit int)
}
res = append(res, w)
}
if rows.Err() != nil {
return nil, rows.Err()
}
return res, nil
}

Expand Down Expand Up @@ -520,6 +534,9 @@ func (c *Connection) GetServiceHotWithdrawalTasks(ctx context.Context, limit int
}
tasks = append(tasks, w)
}
if rows.Err() != nil {
return nil, rows.Err()
}
return tasks, nil
}

Expand Down Expand Up @@ -550,6 +567,9 @@ func (c *Connection) GetServiceDepositWithdrawalTasks(ctx context.Context, limit
}
tasks = append(tasks, w)
}
if rows.Err() != nil {
return nil, rows.Err()
}
return tasks, nil
}

Expand Down Expand Up @@ -729,6 +749,9 @@ func (c *Connection) GetTonInternalWithdrawalTasks(ctx context.Context, limit in
task.Currency = core.TonSymbol
tasks = append(tasks, task)
}
if rows.Err() != nil {
return nil, rows.Err()
}
return tasks, nil
}

Expand Down Expand Up @@ -776,6 +799,9 @@ func (c *Connection) GetJettonInternalWithdrawalTasks(
}
tasks = append(tasks, task)
}
if rows.Err() != nil {
return nil, rows.Err()
}
return tasks, nil
}

Expand Down Expand Up @@ -997,6 +1023,9 @@ func (c *Connection) SetExpired(ctx context.Context) error {
}
ids = append(ids, queryID)
}
if rows.Err() != nil {
return rows.Err()
}

for _, id := range ids {
_, err = tx.Exec(ctx, `
Expand Down Expand Up @@ -1164,6 +1193,9 @@ func (c *Connection) GetIncome(
}
res = append(res, deposit)
}
if rows.Err() != nil {
return nil, rows.Err()
}
return res, nil
}

Expand Down Expand Up @@ -1231,6 +1263,9 @@ func (c *Connection) GetIncomeHistory(
income.Utime = uint32(t.Unix())
res = append(res, income)
}
if rows.Err() != nil {
return nil, rows.Err()
}
return res, nil
}

Expand Down
6 changes: 6 additions & 0 deletions db/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ func Test_SetExpired(t *testing.T) {
extRes[i] = r
i++
}
if rows.Err() != nil {
t.Fatal("rows err: ", rows.Err())
}
if externalResult != extRes {
t.Fatalf("invalid external result pattern: %v", extRes)
}
Expand All @@ -246,6 +249,9 @@ func Test_SetExpired(t *testing.T) {
intRes[i] = r
i++
}
if rows.Err() != nil {
t.Fatal("rows err: ", rows.Err())
}
if internalResult != intRes {
t.Fatalf("invalid internal result pattern: %v", intRes)
}
Expand Down
Loading