Improve some error messages

pull/29/head
Vinícius Garcia 2022-08-27 12:33:18 -03:00
parent 86dd623eac
commit 67ad75242a
2 changed files with 4 additions and 4 deletions

View File

@ -192,11 +192,11 @@ func (c DB) Query(
} }
if rows.Err() != nil { if rows.Err() != nil {
return rows.Err() return fmt.Errorf("KSQL: unexpected error when parsing query result: %w", rows.Err())
} }
if err := rows.Close(); err != nil { if err := rows.Close(); err != nil {
return err return fmt.Errorf("KSQL: unexpected error when closing query result rows: %w", err)
} }
// Update the original slice passed by reference: // Update the original slice passed by reference:

View File

@ -534,7 +534,7 @@ func QueryTest(
var users []user var users []user
err := c.Query(ctx, &users, `SELECT * FROM users`) err := c.Query(ctx, &users, `SELECT * FROM users`)
tt.AssertErrContains(t, err, "fakeErrMsg") tt.AssertErrContains(t, err, "KSQL", "fakeErrMsg")
}) })
t.Run("should report error if DBAdapter.Close() returns an error", func(t *testing.T) { t.Run("should report error if DBAdapter.Close() returns an error", func(t *testing.T) {
@ -560,7 +560,7 @@ func QueryTest(
var users []user var users []user
err := c.Query(ctx, &users, `SELECT * FROM users`) err := c.Query(ctx, &users, `SELECT * FROM users`)
tt.AssertErrContains(t, err, "fakeCloseErr") tt.AssertErrContains(t, err, "KSQL", "fakeCloseErr")
}) })
}) })
}) })