Skip to content

Commit

Permalink
fix unhandled exception
Browse files Browse the repository at this point in the history
  • Loading branch information
aradwann committed Jan 3, 2024
1 parent 57ba1ce commit 2837368
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions db/store/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ func (q *Queries) UpdateUser(ctx context.Context, arg UpdateUserParams) (User, e
}

func scanUserFromRow(row *sql.Row, user *User) error {

err := row.Scan(
&user.Username,
&user.HashedPassword,
Expand All @@ -77,20 +76,16 @@ func scanUserFromRow(row *sql.Row, user *User) error {
&user.PasswordChangedAt,
&user.CreatedAt,
)

// Check for errors after scanning
if err := row.Err(); err != nil {
// Handle row-related errors
log.Fatal(err)
return err
}
if err != nil {
// Check for a specific error related to the scan
// Handle scan-related errors
if err == sql.ErrNoRows {
fmt.Println("No rows were returned.")
return err
} else {
// Handle other scan-related errors
log.Fatal(err)
// Log and return other scan-related errors
log.Printf("Error scanning row: %s", err)
return err
}
}
Expand Down

0 comments on commit 2837368

Please sign in to comment.